Hi I'm writing a class and I want to invoke the print function and I keep getting the error invalid use of a class, my code looks like this:
my cpp
and my header file looks like this:
any help would be much appreciated
my cpp
Code:
#include "/home/chris200x9/Desktop/test4/Pet.h"
#include <iostream>
using namespace std;
Pet::Pet(string n, int a, int w, string t)
{
n = name;
a = age;
w = weight;
t = type;
}
Pet::~Pet(void)
{
};
int Pet::Gain( int gain)
{
return weight + gain;
};
int Pet::Loss( int loss)
{
return weight - loss;
};
void Pet::Print()
{
cout << name << endl;
cout << age << endl;
cout << weight << endl;
cout << type << endl;
}
int main()
{
Pet one;
one.Pet.Print ("mincha",14,4,"dog");
return 0;
}
and my header file looks like this:
Code:
#include <string>
using namespace std;
class Pet
{
private:
string name;
int age;
int weight;
string type;
public:
Pet(void);
Pet(string name, int age, int weight, string type);
~Pet(void);
void Print(void );
int Gain( int gain );
int Loss(int loss);
};
any help would be much appreciated