The contents of the header file Test.h are
class Test
{
public:
virtual void test1();
}
The implementation file is
Test.cpp
#include "Test.h"
#include <iostream>
using namespace std;
void Test::test1(){ cout<<"Hello"<<endl; }
An error occurred at compile time
c:\program files\microsoft visual studio\vc98 \include\errno.h(29) : error C2143: syntax error : missing ';' before 'string'
c:\program files\microsoft visual studio\vc98\include\errno.h(29) : fatal error C1004: unexpected end of file found
Do not connect these two files to consider it is difficult to know is there is wrong, and Unmi originally write Java is much more than C + +, Java can not #include usage, in fact, have C + + experience, understand the #include只是把被包含文件的内容引入到当前位置.
The above inserts the contents of the Test.h into the Test.cpp file #include "Test.h", it should be noted that the class declaration must be followed by a semicolon, you can take the class declaration as a normal variable declaration statement, need to end a semicolon, or there will be many unpredictable compilation errors
The type of error is not just the above, the main content of the document introduced to the current position, and then the statement difference between a semicolon will be a syntax error, so you should form a class declaration after the good habit will not be wrong.
such as the implementation of the file written
#include "Test.h"
void Test::test1(){}
The mistake that comes up is
#include "Test.h"
void Test::test1 () {}
C:\Documents and Settings\yanbin\my documents\visual Studio
Projects\testvirtual\test.cpp (3): Error C2628: ' Test ' followed by
' void ' are illegal (did you forget a '; ')
C:\Documents and Settings\yanbin\my documents\visual Studio
projects\testvirtual\test.cpp (3): Error C2556: ' Class Test __thiscall
test::test1 (void) ': overloaded function differs only with return type from
' void __thiscall test::t Est1 (void) '
C:\Documents and Settings\yanbin\my Documents\Visual Studio
projects\testvirtual\test.h (4): Declaration of ' test1 '
C:\Documents and Settings\yanbin\my documents\visual Studio
projects\testvirtual \test.cpp (3): Error C2371: ' test1 ':
redefinition different basic types
c:\documents and Settings\yanbin\my D Ocuments\visual Studio
projects\testvirtual\test.h (4): declaration ' test1 '
Because the compiler sees no semicolon between the class declaration of the header file and the statement void Test::test1 () {}.