Having trouble with subclass constructor in C++?

 Dont Buy Textbooks. Rent 'EM Save 60-80%



I have a class dog there is to be a subclass of dog called a MexicanHairless with an added property of hair which is set to false (0). How do I create a constructor for MexicanHairless keep getting the error "no appropriate default constructor available."

class Dog

{ protected:

string name;

char gender;

public:

Dog (string theName, char theGender)

{ name = theName;

gender = theGender;}

~Dog ( ) { }

void bark(int n)

{ for (int i =1; i <=n; i++) cout << "rff " << endl; }

void sleep()

{ cout << "zzzz, zzzz" << endl; }

void eat()

{ cout << "slurp" << endl; }

int compare(Dog dog1, Dog dog2)

{ if (dog1.gender == dog2.gender)

if(dog1.name == dog2.name)

return 1;

return 0;

}

};

class MexicanHairlessDog : private Dog{

protected:

int hair;

MexicanHairlessDog()

{

// Here?

}

};

Having trouble with subclass constructor in C++?c++ compiler



The MexicanHairlessDog() constructor needs to call the Dog( string, char ) constructor since it is the only one. Or else you need to create a Dog() constructor in the base class.

MexicanHairlessDog() : Dog(

string("Hairless"),

'F'){

}



More Related Questions and Answers ...
  • Help making a copy constructor in C++?
  • How do yo call a base classes constructor in ..
  • What is the difference between the Assignment..
  • Tell me about shared constructor and private ..
  • What is virtual constructor in C++?
  • Why dont we have virtual constructor in C++ ?
  • Why there is no virtual constructor in C++?
  • What is the use of a constructor in c plus pl..
  • How do you pass 3D arrays through a construct..
  • What is virtual constructor/destructors in c+..
  • C++, why is a copy constructor not needed whe..
  • May i know what is the use of constructor fun..
  • Why the constructor cannot be virtual in C++ ..
  • What is a copy constructor&#039;s purpose..
  • What is a constructor and destructor in C++ ?
  • What is the concept of "constructor idio..
  • In C++ is writing a copy constructor the same..
  • In c++ can an object call its own constructor..
  • Can u say briefly about friend function,const..

  • The information post by website user , we not guarantee correctness.

    

    Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes