Monday, February 28, 2011

Solving 'classname' followed by 'int' is illegal (did you forget a ';'?) error in C++

While doing class based programing in C++, the following error occurs.
 'classname' followed by 'int' is illegal (did you forget a ';'?)
The error occurs if the class declaration is not terminated properly.
Class declarations should end with a semicolon.
In the above program, the class terminates near the yellow marking, but a semicolon is missing.
Remember that the same structure of a "struct" is used for classes too. Structures end with a semicolon,similarly classes should also end with a semicolon.


  1. Anonymous2:23 PM

    Thanks for this, It helped me a lot. :)

  2. Anonymous8:54 PM

    Thanks a lot! Simple semicolon fixed my problem.

  3. Anonymous12:04 AM

    you rock.