Home Forums Programming help with constructors Reply To: help with constructors

#45667
Anonymous
Inactive

so the reason that var can access the private attribue is because of
complex&???[/quote:cebfa15bf2]

Pretty much. I can see the possible confusion because of what you probably know about encapsulation – private, public, protected access modifiers etc. But if you think of those access modifiers are relating to the class implementation and that a copy constructor is part of that class implementation (i.e. its defined in the same header/source file) then it can access private data in the complex class no problem.

And if the code you posted is your own, it’d be better to uppercase the first letter of your classes where possible, i.e. Complex instead of complex.