[Solved] How do I write the copy Constructor for Composition? [closed]
Try like this: #include <string> #include <iostream> class Pulley{ private: int noOfTeeth; public: Pulley(int teeth = 0); void show(); }; Pulley::Pulley(int teeth) : noOfTeeth(teeth) { std::cout << “Pulley constructor called!”; } void Pulley::show() { std::cout << “\n\nNo of Teeths of Pulley: ” << noOfTeeth; } class GearBox{ private: std::string transmission; Pulley p; public: GearBox(std::string trans … Read more