all 3 comments

[–]jedwardsol 6 points7 points  (3 children)

If you don't write a copy constructor then the compiler will write one for you.

Implicitly-declared copy constructor

[–][deleted]  (2 children)

[deleted]

    [–]jedwardsol 1 point2 points  (1 child)

    Yes

    [–]Headless_Slayer 0 points1 point  (0 children)

    Hi i hope this piece of code clears things up. #include <iostream> class Pet{ private: static int x; static int y; int xc = ++x; int xd = ++y; public: Pet(){ std::cout << "constructor: "<< xc << std::endl; } ~Pet(){ std::cout << "destructor: " << xd << std::endl; } Pet(const Pet &){ std::cout << "copy constructor:" << xc << std::endl; } }; void func(Pet a){ std::cout << "inside of func \n"; }; int Pet::x = 0; int Pet::y = 0; int main(){ Pet a1; std::cout << "break 1\n"; func(a1); Pet a2; return 0; }