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.

2 comments:

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

    ReplyDelete
  2. Thanks a lot! Simple semicolon fixed my problem.

    ReplyDelete

Popular Pages