Problem: I am creating a class variable in my C++ program. When I try to assign a variable to a class object , I get the message that my class my not be defined. My class definition is indeed defined. It is right above the main() function where I am trying to use it. Do you know what could cause this? Solution: Note: The information in this document was tested in Borland C++ 5.02. One possible cause of this error is forgetting to place a semicolon after the closed curly brace at the end of the class definition. eg. The following code will generate the 'Type may not be defined here' error. #includeclass mybox { public: int length; int width; int height; char* contents; mybox(int l,int w,int h,char* c); printstring(); } // if you put a semicolon here, you will not // get type may not be defined errors anymore main() { mybox waldo(3,4,5,"black"); waldo.printstring(); }; When you compile the code above, you will get 'Type may not be defined here' error listed for the code in the first line of main() that declares the variable 'waldo'. Placing a semicolon after the class definition will resolve this error.
Last Modified: 23-OCT-00