P
partybob99
I am using Microsoft Visual C++ v1.52. I am trying to build the most
simple class known to mankind, and I cant get it to compile no matter
what I do. I am building the program as a .LIB file and not an .EXE.
I've taken the code from a tutorial manual so the syntax should be
correct.
Here is the code:
class Cat // declare the class object
{
public: // members which follow are public
int itsAge;
int itsWeight;
};
void main()
{
Cat Frisky;
Frisky.itsAge = 5; // assign to the member variable
}
I take this code and paste it into a new .c file and then try to
build. I get the following errors:
error C2282: 'class' is followed by 'Cat' (missing ','?)
error C2065: 'Cat' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'Frisky'
error C2065: 'Frisky' : undeclared identifier
error C2224: left of '.itsAge' must have class/struct/union type
Does anyone know what is going on here? I know "class" is a valid
keyword, but it's like the compiler does not that it's a valid
keyword. I apologize to everyone for being such a moron, but I need
assistance.
Thanks in advance.
Partybob99
simple class known to mankind, and I cant get it to compile no matter
what I do. I am building the program as a .LIB file and not an .EXE.
I've taken the code from a tutorial manual so the syntax should be
correct.
Here is the code:
class Cat // declare the class object
{
public: // members which follow are public
int itsAge;
int itsWeight;
};
void main()
{
Cat Frisky;
Frisky.itsAge = 5; // assign to the member variable
}
I take this code and paste it into a new .c file and then try to
build. I get the following errors:
error C2282: 'class' is followed by 'Cat' (missing ','?)
error C2065: 'Cat' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'Frisky'
error C2065: 'Frisky' : undeclared identifier
error C2224: left of '.itsAge' must have class/struct/union type
Does anyone know what is going on here? I know "class" is a valid
keyword, but it's like the compiler does not that it's a valid
keyword. I apologize to everyone for being such a moron, but I need
assistance.
Thanks in advance.
Partybob99