Content deleted Content added
Default constructors - correction for C++, clarification for other languages. |
Bollocks! While default access level in C++ is public for "struct" and private for "class" this is in no way special behaviour for constructors and thus irrelevant for this article. |
||
Line 253:
y = r*sin(alpha); // <- Normal assignment
}
private:
double x;
double y;
};
Line 265:
c(5, M_PI/4);
</source>
In C++ the copy constructor is called implicitly when class objects are returned from a method by return mechanism or when class objects are passed by value to a function. C++ provides a copy constructor if the programmer does not. The default copy constructor ONLY makes member-wise copy or shallow copies. For deep copies an explicit copy constructor that makes deep copies is required. For a class to make deep copies, the three methods below must be provided.
|