getline() vs. fgets(): Control memory allocation

My question is: Isn’t that dangerous? What if by accident or malicious intent someone creates a 100GB file with no ‘\n’ byte in it – won’t that make my getline() call allocate an insane amount of memory? Yes, what you describe is a plausible risk. However, if the program requires loading an entire line into … Read more

OpenCV houghLinesP parameters

Ok, I finally found the problem and thought I would share the solution for anyone else driven nuts by this. The issue is that in the HoughLinesP function, there is an extra parameter, “lines” which is redundant because the output of the function is the same: cv2.HoughLinesP(image, rho, theta, threshold[, lines[, minLineLength[, maxLineGap]]]) This is … Read more

Need to make a clickable

There are two solutions posted on that page. The one with lower votes I would recommend if possible. If you are using HTML5 then it is perfectly valid to put a div inside of a. As long as the div doesn’t also contain some other specific elements like other link tags. The solution you are … Read more

When/why to make function private in class?

You should make a function private when you don’t need other objects or classes to access the function, when you’ll be invoking it from within the class. Stick to the principle of least privilege, only allow access to variables/functions that are absolutely necessary. Anything that doesn’t fit this criteria should be private.