Horje
constructor syntax in c++ Code Example
constructor syntax in c++
struct S {
    int n;
    S(int); // constructor declaration
    S() : n(7) {} // constructor definition.
                  // ": n(7)" is the initializer list
                  // ": n(7) {}" is the function body
};
S::S(int x) : n{x} {} // constructor definition. ": n{x}" is the initializer list
int main()
{
    S s; // calls S::S()
    S s2(10); // calls S::S(int)
}




Cpp

Related
c++ classes Code Example c++ classes Code Example
range based for loop c++ Code Example range based for loop c++ Code Example
Valid Parentheses leetcode in c++ Code Example Valid Parentheses leetcode in c++ Code Example
stack data structure c++ Code Example stack data structure c++ Code Example
iostream c++ Code Example iostream c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9