I have to write a program that accepts data for a class and then ouputs it in the main.
so far i have this.

#include<iostream>
#include<string>
#include<fstream>
using namespace std;
ifstream infile;
class animal
{
 string species;
 string family;
 string phylum;
 string desc;
 static int count;
public:
 bool readIN(const string fname);
 void printInfo() const;
 void setAnimal (string s, string f, string p,
  string d);
 static int getCount();
 animal(string s, string f, string p, string d);
 animal(ifstream& file, const string fname);
};
int animal::count=4;
bool readIN(const string& fname)
{
 infile.open("cat.txt");
 return infile;
}
void animal::setAnimal (string species, string family, string phylum, string desc)
{
 while(!infile.eof())
 {
  infile>>species;
  infile>>family;
  infile>>phylum;
  infile>>desc;
 }
}
void animal::printInfo() const
{
 animal setAnimal(species, family, phylum, desc); 
 cout << species;
 cout << family;
 cout << phylum;
 cout << desc;
}
static int getCount()
{
 static int count;
 cout << count;
 return count;
}
animal::animal(string species, string family, string phylum, string desc)
{
 species="";
 family="";
 phylum="";
 desc="";
}
animal::animal(ifstream& file, const string fname)
{
 readIN(fname);
}
int main()
{
 int y;
 animal readIN(fname);
 animal setAnimal(species, family, phylum, desc);
 animal printInfo();
 animal getcount();
 cin >> y;
 return 0;
}

I am getting errors in my int main stating that the variables in the first two functions are undefined.
Thanks for help if any

You must have an instance of the animal class in order to use it.

int main()
{
   animal a;
   a.ReadIN(fname);
   a.setAnimal(....)
   etc
   etc
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.