Error C2628 Example 1: 'x' followed by 'x' is illegal


This type of error is generated by the common mistake of forgetting to put the semicolon at the end of the class declaration. In this simple example, there is only one file in the project (main.cpp) and the error is relatively easy to find. In a more typical project, a header that is missing a semicolon can be included in multiple other files, where the errors will often be difficult to understand. To find the mistake, look at the included headers files and make sure that a semicolon is present.

Code with Errors:

Compiler Error Message:

1>------ Build started: Project: myproj, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\\myproj\myproj\main.cpp(10): error C2628: 'CPoint' followed by 'int' is illegal
1>					(did you forget a ';'?)
1>c:\\myproj\myproj\main.cpp(10): error C3874: return type of 'main' should be 'int'
1>					instead of 'CPoint'
1>c:\\myproj\myproj\main.cpp(16): error C2440: 'return' : cannot convert from 'int'
1>					to 'CPoint'
1>          No constructor could take the source type, or constructor overload resolution
1>					was ambiguous
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Fixed Code:


C2628 Example 1 Output