programming_languages:cpp:constructor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
programming_languages:cpp:constructor [2017/02/19 14:46] – ↷ Seite von programmiersprachen:cpp:constructor nach programming_languages:cpp:constructor verschoben phreazerprogramming_languages:cpp:constructor [2020/05/29 16:40] (current) phreazer
Line 1: Line 1:
 ====== Basic constructor ====== ====== Basic constructor ======
  
 +<code>
 class Example class Example
 { {
Line 16: Line 17:
     cout << "Constructor was called" << endl;     cout << "Constructor was called" << endl;
 } }
 +</code>
  
 ====== Initialization lists to initialize members ====== ====== Initialization lists to initialize members ======
  
 +<code>
 Example::Example( double someDoubleParam): someDouble(someDoubleParam) Example::Example( double someDoubleParam): someDouble(someDoubleParam)
 { {
        cout << "Constructor was called" << endl;        cout << "Constructor was called" << endl;
 } }
 +</code>
  
 ====== Create objects ====== ====== Create objects ======
  
 +<code>
 int x(5); // (int x = 5) int x(5); // (int x = 5)
 Fraction fiveThirds(5, 3); // Fraction fiveThirds = Fraction(5,3)  Fraction fiveThirds(5, 3); // Fraction fiveThirds = Fraction(5,3) 
 +</code>
  • programming_languages/cpp/constructor.1487515591.txt.gz
  • Last modified: 2017/02/19 14:46
  • by phreazer