Skip to content

Instantly share code, notes, and snippets.

@benoxoft
Created September 5, 2017 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benoxoft/d3bab07393d30722235ec5e91f8f5d4d to your computer and use it in GitHub Desktop.
Save benoxoft/d3bab07393d30722235ec5e91f8f5d4d to your computer and use it in GitHub Desktop.
null created by benoxoft - https://repl.it/Kgxj/1
#include <iostream>
using namespace std;
class Widget {
public:
Widget(int i, bool b); // ctors not declaring
Widget(int i, double d); // std::initializer_list params
};
Widget::Widget(int i, bool b) {
cout << "Constructeur #1" << endl;
cout << i << endl;
cout << b << endl;
}
Widget::Widget(int i, double d) {
cout << "Constructeur #2" << endl;
cout << i << endl;
cout << d << endl;
}
int main() {
Widget w1(10, true); // calls first ctor
Widget w2{10, true}; // also calls first ctor
Widget w3(10, 5.0); // calls second ctor
Widget w4{10, 5.0}; // also calls second ctor
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment