Don’t understand static boolean behavior

static in this context means “local” (to the translation unit). There will be multiple copies of read_mess in your program, one per translation unit which is not the same thing as a header file. (In your case you can most likely approximate “translation unit” as .cpp or .c or .cc file). Probably what you meant to do was to declare an extern variable, or static class … Read more

error: switch quantity not an integer

In switch, the expression must be of “an integral type or of a class type for which there is an unambiguous conversion to integral type” (quoting VS2008 docs). A string class doesn’t have “unambiguous conversion to integral type”, like a char does. As a work-around: Create a map<string, int> and switch on the value of the map: switch(command_map[command]) ` Do a set of if/else instead of … Read more

C++ pass an array by reference

Arrays can only be passed by reference, actually: This prevents you from doing things like: To be able to pass an arbitrary size array to foo, make it a template and capture the size of the array at compile time: You should seriously consider using std::vector, or if you have a compiler that supports c++11, std::array.

In C++ can constructor and destructor be inline functions?

Defining the body of the constructor INSIDE the class has the same effect of placing the function OUTSIDE the class with the “inline” keyword. In both cases it’s a hint to the compiler. An “inline” function doesn’t necessarily mean the function will be inlined. That depends on the complexity of the function and other rules.

OpenCV Error: Assertion failed (size.width>0 && size.height>0) simple code

This error means that you are trying to show an empty image. When you load the image with imshow, this is usually caused by: The path of your image is wrong (in Windows escape twice directory delimiters, e.g. imread(“C:\path\to\image.png”) should be: imread(“C:\\path\\to\\image.png”), or imread(“C:/path/to/image.png”)); The image extension is wrong. (e.g. “.jpg” is different from “.jpeg”); You don’t have the rights … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)