#include "testView.h" in MainFrm.cpp [modified]
-
I create a SDI project with VC 6.0. I have to put
#include "testView.h"
in the file MainFrm.cpp, since I need to link testView to a splitted window pane using
wndSplitter_horizontal.CreateView(0,0,RUNTIME_CLASS(CTestView),CSize(50,50),pContext);
However, the compiler complaint with the following lines.
d:\vc_project\test\testview.h(27) : error C2143: syntax error : missing ';' before '*'
d:\vc_project\test\testview.h(27) : error C2501: 'CTestDoc' : missing storage-class or type specifiers
d:\vc_project\test\testview.h(27) : error C2501: 'GetDocument' : missing storage-class or type specifiersThe error can be replayed easily by creating a SDI project and typing in the MainFrm.cpp file
#include "TestView.h"
i have had a look online, but found no solutions.
modified on Friday, January 7, 2011 9:18 AM
-
I create a SDI project with VC 6.0. I have to put
#include "testView.h"
in the file MainFrm.cpp, since I need to link testView to a splitted window pane using
wndSplitter_horizontal.CreateView(0,0,RUNTIME_CLASS(CTestView),CSize(50,50),pContext);
However, the compiler complaint with the following lines.
d:\vc_project\test\testview.h(27) : error C2143: syntax error : missing ';' before '*'
d:\vc_project\test\testview.h(27) : error C2501: 'CTestDoc' : missing storage-class or type specifiers
d:\vc_project\test\testview.h(27) : error C2501: 'GetDocument' : missing storage-class or type specifiersThe error can be replayed easily by creating a SDI project and typing in the MainFrm.cpp file
#include "TestView.h"
i have had a look online, but found no solutions.
modified on Friday, January 7, 2011 9:18 AM
-
You should include TestDoc.h as well since CTestView depends on it. In my opinion, that should have been taken care of in the TestView.h file, to make it self supporting. But sometimes compilation speed is preferred over ease-of-use.
Thank you for your reply. when I create a SDI project with AppWizard, I notice there are lines in the testView.h file
public:
CTestDoc* GetDocument();but there is no #include "testDoc.h". The program works fine though. However,when I simply put the line
#include "testView.h"
into the MainFrm.cpp file the error message pops up. I think the error message is suppose to occur in the former case.
-
Thank you for your reply. when I create a SDI project with AppWizard, I notice there are lines in the testView.h file
public:
CTestDoc* GetDocument();but there is no #include "testDoc.h". The program works fine though. However,when I simply put the line
#include "testView.h"
into the MainFrm.cpp file the error message pops up. I think the error message is suppose to occur in the former case.
The reason it works fine in the first case is because in all files where testView.h is included (test.cpp and testView.cpp in a standard project), testDoc.h is included before testView.h.
#include "testDoc.h"
#include "testView.h"So the advice to include testDoc.h first, is correct.
-
The reason it works fine in the first case is because in all files where testView.h is included (test.cpp and testView.cpp in a standard project), testDoc.h is included before testView.h.
#include "testDoc.h"
#include "testView.h"So the advice to include testDoc.h first, is correct.
I see now. Thanks