#include "class1.h"
usingnamespace std;
class class1{
void class1::setSomething(int x, int y){
class1::x = x;
class1::y = y;
}//end class1
void class1::printSomething(){
cout << "the sum is: " << (x+y) << " .\n";
}
};
I receive error c2011, the full error below. There are other errors as well.
D:\...\proj1\test.cpp|1|warning C4067: unexpected tokens following preprocessor directive - expected a newline|
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xlocale|342|warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc|
D:\...\proj1\test.cpp|6|error C2011: 'class1' : 'class' type redefinition|
D:\...\proj1\test.cpp|27|error C2079: 'test' uses undefined class 'class1'|
D:\...\proj1\test.cpp|33|error C2228: left of '.setSomething' must have class/struct/union|
D:\...\proj1\test.cpp|34|error C2228: left of '.printSomething' must have class/struct/union|
||=== Build finished: 4 errors, 2 warnings ===|
I created a brand new project in VS2008 with the same code as above (adding #include <iostream>;) and receive the same C2011 error. Here's the error according to VS2008
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Compiling...
1>class1.cpp
1>d:\...\class1.cpp(5) : error C2011: 'class1' : 'class' type redefinition
1> d:\...\class1.h(4) : see declaration of 'class1'
1>Build log was saved at "file://d:\...\BuildLog.htm"
1>test - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========