Apologies if this is below the community's paygrade. I only started learning about OOP and classes last night and English is not my native language.
I am trying to create a class called "Mammal" with its name, type of fur, number of legs and the presence of a tail as properties. This is what my mammal.h looks like.
//mammal.h
#include <string>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class Mammal
{
public:
//Properties
enum Fur {bald, curly, frizzy, matted, shorthair, longhair, fluffy};
Fur flooftype;
int Legs;
bool Tail;
string Name;
//Methods
Mammal(string Name, Fur flooftype, int Legs, bool Tail);
void identifyMammal(string Name, Fur flooftype, int Legs, bool Tail)
{
cout<<"Name: " << Name << endl;
cout<<"Number of legs: "<< Legs << endl;
cout<<"Fur type: "<< flooftype << endl;
if(Tail==true){
cout<<"This mammal has a tail.";
}else{
cout<<"This mammal has no tail.";
}
}
};
Mammal::Mammal(string Name, Fur flooftype, int Legs, bool Tail)
{
Name=Name;
flooftype=flooftype;
Legs=Legs;
Tail=Tail;
}
And this is my main.cpp:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include "mammal.h"
using namespace std;
int main()
{
Mammal cat1;
cout << Mammal.identifyMammal() << "." <<endl;
cout << endl;
system ("pause");
return EXIT_SUCCESS;
}
I am unable to get this code to compile, it gives me the following errors:
no default constructor exists for class "Mammal"
type name is not allowed
I'm not sure why it's not recognizing my constructor. Can anyone point me in the right direction?