Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int counter1 = 0;
- class C {
- int c = counter1++;
- public:
- C() {
- std::cout << "constructor C() " << c << "\n";
- }
- C(const C& other) {
- std::cout << "constructor C(const C&) " << c << "\n";
- }
- C(C&& other) {
- std::cout << "constructor C(const C&&) " << c << "\n";
- }
- C& operator = (const C& other) {
- std::cout << "operator = (const C&) " << "\n";
- return *this;
- }
- C& operator = (C&& other) {
- std::cout << "operator = (const C&&)\n";
- return *this;
- }
- ~C() {
- std::cout << "destructor C() " << c << "\n";
- }
- };
- int counter2 = 0;
- class D {
- private:
- C c1;
- const C& c2;
- const C* c3;
- int c = counter2++;
- public:
- D(const C& arg1, const C& arg2, const C* arg3) :
- c1(arg1),
- c2(arg2),
- c3(arg3) {
- std::cout << "constructor D(const C&, const C&, const C*) " << c << "\n";
- }
- ~D() {
- std::cout << "destructor D() " << c << "\n";
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement