I have this program I am doing for a class and I keep on getting the same error on the way my functions are being called.
45 C:\Dev-Cpp\ no matching function for call to `circus::getanimal()'
note C:\Dev-Cpp\:15 candidates are: void circus::getanimal(std::string, std::string, int)
46 C:\Dev-Cpp\ no matching function for call to `tiger::getstripes()'
note C:\Dev-Cpp\REDOCIRCUS.cpp:26 candidates are: void tiger::getstripes(std::string, int)
and so on..
any help would be greatly appreciated
Code:
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;
class circus
{
public:
string animaltype;
string animalname;
int age;
int dailyfood;
void getanimal(string animalname, string animaltype,int animalage);
void getfood();
};
class tiger : public circus
{
public:
int stripes;
int toothlength;
char maneater;
int jumpdistance;
private:
void getstripes(string animalname, int stripes);
};
class elephant : public circus
{
public:
int tusks;
string eletype;
int num;
private:
void gettype(int tusks,int num, string eletype, string animalname);
};
circus animals;
tiger cat;
elephant grey;
int main()
{
cout << "Hello and welcome to the super fantastic circus!" << endl << "Please enter the following information by pressing enter after each input" << endl;
animals.getanimal();
cat.getstripes();
grey.gettype();
system("pause");
return 0;
}
void circus::getanimal(string animalname, string animaltype,int animalage)
{
cout << "What is your animal's name?" << endl;
cin >> animalname;
cout << "what kind of animal is" << animalname << "?" << endl;
cin >> animaltype;
cout << "what is " << animalname << "'s" << "age?" << endl;
cin >> animalage;
cout << animalname << "is a" << animaltype << "and is" << animalage << "years old." << endl;
}
void circus::getfood()
{
cout << "Please enter the animal's name." << endl;
cin >> animalname;
cout << "Please enter the amout of food" << animalname << "eats" << endl;
cin >> dailyfood;
cout << animalname << "eats" << (dailyfood * 7) << "in one week" << endl;
}
void tiger::getstripes(string animalname, int stripes)
{
cout << "Please enter the name of the tiger." << endl;
cin >> animalname;
cout << "Please enter the number of stripes" << animalname << "has." << endl;
cin >> stripes;
cout << "So" << animalname << "has" << stripes << endl;
}
void elephant::gettype(int tusks,int num, string eletype, string animalname)
{
cout << "What type of elephant is " << animalname << "?" << "Type 1 for African and 2 for Asian" << endl;
cin >> num;
if (num == 1)
(eletype = "African");
else
(eletype = "Asian");
cout << "Does " << animalname << "have tusks type 1 for yes and 2 for no" << endl;
cin >> tusks;
if (tusks == 1)
cout << animalname << " is a " << eletype << " elephant and does have tusks " << endl;
else
cout << animalname << " is a " << eletype << " elephant and does not have any tusks " << endl;
}