Hey all,
I am trying to figure this class thing out and still cannot get it right.
I keep on getting these errors which make no sense to me at all and even worse I am using a template right out of the book.
here is the code:
Code:
#include <iostream.h>
#include <string>
class dog
{
private:
public:
void bark(void);
void chasecar(void);
void beg(void);
dog();
};
//Constructor
dog::dog()
{
}
void dog::bark(void)
{
int x;
for(x= 0; x < 5; x++)
{
cout <<"Bark" << endl;
}
cout << "The squirrl ran away" <<endl;
}
void dog::chasecar(void)
{
int y;
for(y = 0; y < 5; y++)
{
cout << "Vroom!" << endl;
}
cout << "The dog must have got tired" << endl;
}
void dog::beg(void)
{
cout <<"Look at those eyes" << endl;
}
int main()
{
dog harry();
harry.bark(void);
harry.beg(void);
harry.chasecar(void);
cin.ignore(256, '\n');
cout << "Press ENTER to continue..." << endl;
cin.get();
return 0;
}
I am going to try inserting a string to name the damn dog but that wasn't working at all because the compiler refused to recognize 'string' anywhere. I deleted it for now but still keep getting these errors I cannot fix.
55 C:\Documents and Settings\Bill\My Documents\class dog.cpp request for member `bark' in `harry', which is of non-class type `dog ()()'
55 C:\Documents and Settings\Bill\My Documents\class dog.cpp expected primary-expression before "void"
56 C:\Documents and Settings\Bill\My Documents\class dog.cpp request for member `beg' in `harry', which is of non-class type `dog ()()'
56 C:\Documents and Settings\Bill\My Documents\class dog.cpp expected primary-expression before "void"
every single function I use I get this error and I have no idea what's causing it
Thanks
Bill