m_Video is instantiated in main.cpp but General.h declared it as extern (about this extern I have shown in the previous post)
But that is meaningless, because if I write:
(the thing added is in blue) then it tells me "error C2079: 've' uses undefined class 'App::VideoEngine'". The problem is not with m_Video but with App::VideoEngine.
I have attached a zip containing the files of the project.
Last edited by Feoggou; March 8th, 2011 at 09:26 AM.
below is what you have stated. It works fine. You aren't telling the whole story. post a small complete example that shows the problem. I looked your zip - it's not complete since it requires third party libs to build.
gen
Code:
#pragma once
namespace App
{
class MainWnd;
class VideoEngine;
extern MainWnd mainWnd;
extern VideoEngine m_Video;
}
#include "Vid.h"
vid
Code:
#pragma once
#include "gen.h"
namespace App
{
class VideoEngine
{
};
}
the compile error is in Exceptions.h, in the constructor, where it calls:
Code:
App::VideoEngine ve;
Why are you writing implementation code in a header? Forward declaring lets you get away without #include-ing. BUT it means you cant use the type. You cant have your cake and eat it. Use of the type should be in a .cpp file where the type is 'fully' #include-ed
The zip is empty.
Last edited by Amleto; March 9th, 2011 at 07:04 AM.
Why are you writing implementation code in a header? Forward declaring lets you get away without #include-ing. BUT it means you cant use the type. You cant have your cake and eat it. Use of the type should be in a .cpp file where the type is 'fully' #include-ed
Well, it was an easy thing to put the inline functions in the header and don't use another .cpp file for one or two short inline functions.
Ok. thanks for helping me. The problem is solved. Perhaps I should care only not to use inline functions in headers if they require files included, rather than caring about why the headers get messed up.
Last edited by Feoggou; March 9th, 2011 at 08:05 AM.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.