Making use of a different constructor for the single class. - C++ Class

C++ examples for Class:Constructor

Description

Making use of a different constructor for the single class.

Demo Code

#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");
}

Related Tutorials