Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
C++Bro123 (talk | contribs)
m C++: Improve C++ example
Line 286:
<source lang="cpp">
class Foobar {
public:
Foobar(double r = 1.0,
double alpha = 0.0) // Constructor, parameters with default values.
: xx_(r * cos(alpha)) // <- Initializer list
{
yy_ = r * sin(alpha); // <- Normal assignment
}
 
private:
double xx_;
double yy_;
};
</source>