I was reading some C++ code from a basic CPU emulator and I just can't understand this:
class CPU {
private:
CPU (const CPU&){}
};
I understand pointers, I also checked this: Ampersand & with const in constructor. Apparently it is a (hard) copy constructor, but I don't understand, how does this work? why const? Why the ampersand in the end without a var name? Why private? I haven't found an example like this in my books or cplusplus.com.
On a side note:
int foo(int var) { cout << var; }
int bar(int &var) { cout << var; }
foo and bar print the same thing? bar is essentially printing *&var?
Any help is appreciated!