|
Maybe I should have said "virtual functions don't work correctly if called from the base class constructor"?
I thought it was pretty obvious though. In the second example you gave, the compiler will probably make a normal call instead of a virtual one.. If there was another class deriving from Derived and overriding foo(), then the call you made is illegal.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
Hmmm, what is the purpose of the register function ? In fact what do you want to achieve by doing this ? Something like having somewhere a 'list' of all the pluggins in your application ? (And these pluggins are 'registered' on their own creation ?)
What you could do, is manage this inside a 'pluggins manager' (or something like that) which one member function is the register function and one member variable is the list with all the vector:
class CPlugginManager
{
public:
Register(CBasePluggin* pPluggin)
{
m_Pluggins.push_back(pPluggin);
}
private:
std::vector<CBasePluggin*> m_Pluggins;
};
(something like that)
This pluggin manager is implemented as a singleton (see at the end) so that it can be accessed inside the constructors of all your derived pluggins:
CPluggin1:CPluggin1()
{
....
CPlugginManager::GetInstance()->Register(this);
};
To implement the pluggin manager as a singleton, make the constructor protected (!! IMPORTANT).
And add this:
class CPlugginManager
{
public:
static CPlugginManager* GetInstance();
protected:
CPlugginManager();
private:
static CPlugginManager* m_pInstance;
};
CPlugginManager* CPlugginManager::GetInstance()
{
if (m_pInstance==NULL)
m_pInstance = new CPlugginManager;
return m_pInstance;
};
Hope this helps (if I understood well your question )
|
|
|
|
|
Thanks for all nice suggestions!
Though there still is one thing I don't get. How do I get each plugin-class to "execute" itself? Since I don't know about the plugins in main() I can't use them there until they are stored in this register-vector - and if I don't use them in main() the thread of execution goes past the plugins and hence they don't initilize...right ? A bit of a catch-22...
|
|
|
|
|
I think it is pretty tough to do it using just C++. You need some way to discover the presence of plugins and instantiate them.. You can use COM to do that, or use reflection in .NET.. Or you could simply have dlls that are loaded automatically at startup and get scanned for the presence of certain predefined entry points..
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
Without using GetDiskFreeSpaceEx to get the directory space immediately.
(GetDiskFreeSpaceEx - Give Volume space)
is it in registry ??
inbha.
|
|
|
|
|
Hello,
How to select another form using tree view( When I click the icon in the tree a form should display). Please help me.
Thanks
goood
|
|
|
|
|
|
I am using a SpinButton control to let the user select a value. If the user selects a new value then I want a listctrl to immediately repaint itself to show a response to this value change. The repainting only occurs when I scroll down the list control. I am using C++ on Visual Studio 2003 .NET.
My question is how do I force the list control to repaint itself, so that I don't have to scroll up or down to get a repaint? I have tried sending messages to the list ctrl and even invalidating the client area of the list ctrl.
I am the handsome one in the crowd.
|
|
|
|
|
Invalidating only queues up paint events by adding to the accumulating invalid rectangle.
You might want to try the InvalidateRect followed by an UpdateWindow call.
|
|
|
|
|
Hi all,
I want to send packets that contains informations between computers in a local
Network but I haven't IP address of these computers.
How can I do this?
Thabks.
|
|
|
|
|
dSolariuM wrote:
...but I haven't IP address of these computers.
Use gethostbyname() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
How can I programitaclly share a file?
Thanks.
|
|
|
|
|
|
I have tried using a <textarea> on one of the HTML pages in an Application Wizard for Visual Studio 2003 .NET. I use it to obtain multi-line user input.
My problem is that when I press ENTER or CTRL+ENTER to go to the next line in the <textarea> the Application Wizard immediately finishes and starts generating the project but of course crashes with a message that it can't find the root file for the project.
Anybody with ideas or examples?
I am the handsome one in the crowd.
|
|
|
|
|
How does one debug an Application Wizard designed for Visual Studio 2003 .NET?
Mostly I want to debug the JScript part of it. On Internet Explorer I have set the option of "Disable Script debugging" to No. When I open one of the HTML files and I answer yes to the question of wanting to debug the script nothing happens.
I am the handsome one in the crowd.
|
|
|
|
|
Hi,
I want to copy a bitmap from a source rectangle into a destination rectangle,
there are different size.
I use StretchBlt,but it is very slow.
Can anyone tell me how to speedup it?
|
|
|
|
|
|
Check maybe you need to define _WIN32_WINNT to be 0x0500
|
|
|
|
|
Thank you for the reply.
I have defined _WIN32_WINNT, but still it does not compile.
What I notice in my system is that QueueUserWorkItem(...) declaration is present in the "winbase.h" header file found in my [C:\Program Files\Microsoft SDK\include] folder. But the VC++ IDE is including the "winbase.h" from folder [C:\Program Files\Microsoft Visual Studio\VC98\Include] which does not have the declaration for QueueUserWorkItem(...)
Can you figure out what is wrong for my app not to compile?
Regards,
Senthil.
|
|
|
|
|
In the IDE you can change the order in which the Include folders are searched. Make sure the (February '01) SDK version is at the top of the list.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Go to Tools->Options and click on the "Directories" tab.
Change the order in the list.
|
|
|
|
|
Hi guys
I need to get an XML file from internet and parse it to get some values.
I'm newbie in these kind of things.
I've seen XmlViewer class here in CodeProject pretty good (it only read files from HD I think) but to read a file from internet what is supossed that I have to do?
I repeat that I'm newbie working with internet files.
Could you redirect me to an example that shows how to get and open an internet file, maybe with this and with the XmlViewer found here in Codeproject it will be enough to understand and do what I have to do.
Thanks in forwarding
Doc
|
|
|
|
|
|
Thanks a lot
I sure think Believe this will help!!!!
Doc
|
|
|
|