The #include exists, but I get an error: identifier “cout” is undefined. Why?

You need to specify the std:: namespace: Alternatively, you can use a using directive: I should add that you should avoid these using directives in headers, since code including these will also have the symbols brought into the global namespace. Restrict using directives to small scopes, for example Here, the using directive only applies to the scope of foo().

Fatal error: iostream: No such file or directory in compiling C program using GCC

Neither <iostream> nor <iostream.h> are standard C header files. Your code is meant to be C++, where <iostream> is a valid header. Use a C++ compiler such as clang++ or g++ (and a .cpp file extension) for C++ code. Alternatively, this program uses mostly constructs that are available in C anyway. It’s easy enough to convert the entire program to compile using a C compiler. Simply remove #include … Read more

error: expected unqualified-id before ‘if’

You can’t have free-standing code like that. All code needs to go into functions. Wrap all that in a main function and you should be ok once you’ve fixed your use of QTextStream (it has no eof method, and it doesn’t have a readline method either – please look at the API docs that come with usage examples).

unsigned int vs. size_t

The size_t type is the unsigned integer type that is the result of the sizeof operator (and the offsetof operator), so it is guaranteed to be big enough to contain the size of the biggest object your system can handle (e.g., a static array of 8Gb). The size_t type may be bigger than, equal to, or smaller than an unsigned int, and your compiler … Read more

‘typeid’ versus ‘typeof’ in C++

C++ language has no such thing as typeof. You must be looking at some compiler-specific extension. If you are talking about GCC’s typeof, then a similar feature is present in C++11 through the keyword decltype. Again, C++ has no such typeof keyword. typeid is a C++ language operator which returns type identification information at run time. It basically returns a type_info object, which … Read more

Passing a 2D array to a C++ function

There are three ways to pass a 2D array to a function: The parameter is a 2D arrayint array[10][10]; void passFunc(int a[][10]) { // … } passFunc(array); The parameter is an array containing pointersint *array[10]; for(int i = 0; i < 10; i++) array[i] = new int[10]; void passFunc(int *a[10]) //Array containing pointers { // … Read more

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