C++ examples for Class:Constructor
Making use of a different constructor for the single class.
#include <iostream> using namespace std; class Clutter/* www.j a va2 s . c o m*/ { protected: string ChildName; int Toys; public: Clutter(int count, string name) { ChildName = name; Toys = count; } Clutter(string name) { ChildName = name; Toys = 0; } }; int main() { Clutter inst1("A"); Clutter inst2(123, "B"); }