Error: free(): invalid next size (fast):

It means that you have a memory error. You may be trying to free a pointer that wasn’t allocated by malloc (or delete an object that wasn’t created by new) or you may be trying to free/delete such an object more than once. You may be overflowing a buffer or otherwise writing to memory to which you shouldn’t be writing, causing heap corruption. Any … Read more

error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’

C++03 3.10/1 says: “Every expression is either an lvalue or an rvalue.” It’s important to remember that lvalueness versus rvalueness is a property of expressions, not of objects. Lvalues name objects that persist beyond a single expression. For example, obj , *ptr , ptr[index] , and ++x are all lvalues. Rvalues are temporaries that evaporate at the end of the full-expression in which … Read more

c++ –

The type of pointer-to-member-function is different from pointer-to-function. The type of a function is different depending on whether it is an ordinary function or a non-static member function of some class: And Note: if it’s a static member function of class Fred, its type is the same as if it were an ordinary function: “int (*)(char,float)” In C++, member functions have … Read more

error C2106: ‘=’ : left operand must be l-value

This error is being thrown for the same reason you can’t do something like this: Your version of Vector::at should be returning a reference rather than a value.Lvalues are called Lvalues because they can appear on the left of an assignment. Rvalues cannot appear on the left side, which is why we call them rvalues. You can’t … Read more

invalid use of non-static data member

In C++, unlike (say) Java, an instance of a nested class doesn’t intrinsically belong to any instance of the enclosing class. So bar::getA doesn’t have any specific instance of foo whose a it can be returning. I’m guessing that what you want is something like: But even for this you may have to make some changes, because in versions of C++ … Read more

Error: macro names must be identifiers using #ifdef 0

The #ifdef directive is used to check if a preprocessor symbol is defined. The standard (C11 6.4.2 Identifiers) mandates that identifiers must not start with a digit: The correct form for using the pre-processor to block out code is: You can also use: but you need to be confident that the symbols will not be inadvertently set by code … Read more

What does the fpermissive flag do?

Right from the docs: -fpermissiveDowngrade some diagnostics about nonconformant code from errors to warnings. Thus, using -fpermissive will allow some nonconforming code to compile. Bottom line: don’t use it unless you know what you are doing!

Use the auto keyword in C++ STL

The auto keyword is simply asking the compiler to deduce the type of the variable from the initialization. Even a pre-C++0x compiler knows what the type of an (initialization) expression is, and more often than not, you can see that type in error messages. The auto keyword simply allows you to take advantage of this … Read more

What is the meaning of a C++ Wrapper Class?

A “wrapper class” is a de facto term meaning a class that “wraps around” a resource; i.e, that manages the resource. When people write a wrapper, then, they are doing something like this: This class manages (“wraps”) a pointer to an int. All resources should be wrapped in some fashion, for cleanliness (no explicit clean … Read more

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