where is the official c++ documentation

The official C++ “documentation” is the C++ standard, ISO/IEC 14882:2014(E). There is information at ISOCPP how to obtain the document. I wouldn’t necessarily consider the standard good documentation but it does specify the behavior of the standard language and library constructs. There isn’t any other official document on C++ describing the entire language. There are good derivative works making … Read more

Inheriting constructors

If your compiler supports C++11 standard, there is a constructor inheritance using using (pun intended). For more see Wikipedia C++11 article. You write: This is all or nothing – you cannot inherit only some constructors, if you write this, you inherit all of them. To inherit only selected ones you need to write the individual constructors manually and … Read more

“&” meaning after variable type

It means you’re passing the variable by reference. In fact, in a declaration of a type, it means reference, just like: declares a reference to x, called y.

How does ifstream’s eof() work?

-1 is get‘s way of saying you’ve reached the end of file. Compare it using the std::char_traits<char>::eof() (or std::istream::traits_type::eof()) – avoid -1, it’s a magic number. (Although the other one is a bit verbose – you can always just call istream::eof) The EOF flag is only set once a read tries to read past the end of the file. If I … Read more

C ++ error: a expected initializer before [function name]

The return type for stringThing must be either void or string, not both. You also must include <string>, if you want to use string. Since you want to output the return value of stringThing() in main, I guess it should be But then, you must also return a string from your function for example. Your parameter std::string &teststring won’t work with your const char* argument. So either declare … Read more

Why doesn’t C++ have a garbage collector?

Implicit garbage collection could have been added in, but it just didn’t make the cut. Probably due to not just implementation complications, but also due to people not being able to come to a general consensus fast enough. A quote from Bjarne Stroustrup himself: I had hoped that a garbage collector which could be optionally … Read more

How to convert a single char into an int [duplicate]

You can utilize the fact that the character encodings for digits are all in order from 48 (for ‘0’) to 57 (for ‘9’). This holds true for ASCII, UTF-x and practically all other encodings (see comments below for more on this). Therefore the integer value for any digit is the digit minus ‘0’ (or 48). … Read more