Member declaration not found

“Member declaration not found” is an error produced by the Eclipse static analysis tool (codan). If you get this error, but the compilation succeeds this is a false positive. Older versions of this tool are known to give some false positives, see for example this bug report. So I recommend updating Eclipse CDT to the most …

Read more

cin.ignore(numeric_limits::max(), ‘\n’)

This line ignores the rest of the current line, up to ‘\n’ or EOF – whichever comes first: ‘\n’ sets the delimiter, i.e. the character after which cin stops ignoring numeric_limits<streamsize>::max() sets the maximum number of characters to ignore. Since this is the upper limit on the size of a stream, you are effectively telling cin that there is no limit to the number of …

Read more

How to create a vector of class objects in C++?

This is actually a function declaration. The function is called myStack and it returns a vector<Site>. What you actually want is: The type of neighbours at the moment will store copies of the objects, not references. If you really want to store references, I recommend using a std::reference_wrapper (rather than using pointers):

Destructor for a doubly-linked list that points to its value

You need to pair each new with exactly one delete. That is, you probably don’t want to delete prev (this node already was deleted) but you want to delete value. Well, I’d embed the value into the object and not point to it: If the value absolutely needs to be a pointer, I’d use a std::unique_ptr<int> (or, if you need to use C++ 2003, a std::auto_ptr<int>).

How to write std::string to file?

You’re currently writing the binary data in the string-object to your file. This binary data will probably only consist of a pointer to the actual data, and an integer representing the length of the string. If you want to write to a text file, the best way to do this would probably be with an ofstream, an …

Read more