Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Test {
- public Test() {
- DoSomething();
- }
- public Test(int count) : this() {
- DoSomethingWithCount(count);
- }
- public Test(int count, string name) : this(count) {
- DoSomethingWithName(name);
- }
- }
- class Foo {
- public:
- Foo(char x, int y=0); // combines two constructors (char) and (char, int)
- ...
- };
- class Foo {
- public:
- Foo(char x);
- Foo(char x, int y);
- ...
- private:
- void init(char x, int y);
- };
- Foo::Foo(char x)
- {
- init(x, int(x) + 7);
- ...
- }
- Foo::Foo(char x, int y)
- {
- init(x, y);
- ...
- }
- void Foo::init(char x, int y)
- {
- ...
- }
- class Foo {
- public:
- Foo(char x, int y) {}
- Foo(int y) : Foo('a', y) {}
- };
- class SomeType
- {
- int number;
- public:
- SomeType(int newNumber) : number(newNumber) {}
- SomeType() : SomeType(42) {}
- };
- class Foo() {
- Foo() { /* default constructor deliciousness */ }
- Foo(Bar myParam) {
- new (this) Foo();
- /* bar your param all night long */
- }
- };
- class Foo {
- int d;
- public:
- Foo (int i) : d(i) {}
- Foo () : Foo(42) {} //new to c++11
- };
- class Foo {
- int d = 5;
- public:
- Foo (int i) : d(i) {}
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement