Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Basic constructor ====== <code> class Example { public: void someMethod( double someDouble ); double someFunction( void ); Example(); // This is the constructor private: double someDouble; }; Example::Example(void) { cout << "Constructor was called" << endl; } </code> ====== Initialization lists to initialize members ====== <code> Example::Example( double someDoubleParam): someDouble(someDoubleParam) { cout << "Constructor was called" << endl; } </code> ====== Create objects ====== <code> int x(5); // (int x = 5) Fraction fiveThirds(5, 3); // Fraction fiveThirds = Fraction(5,3) </code> programming_languages/cpp/constructor.txt Last modified: 2020/05/29 16:40by phreazer