Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

what happen if I use this in exe file

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#ifdef PLUGIN_EXPORTS
#define PLUGINDECL __declspec(dllexport)
#else
#define PLUGINDECL __declspec(dllimport)
#endif

main(){}

class  PLUGINDECL IPlugin
{
protected:
	virtual initial();
};


class PLUGINDECL A :public IPlugin
{
	initial(){}
};

IPlugin I;


I have 3 quesion: 1. If I use PLUGINDECL in exe other than dll what will happen? 2. Can I instantiate IPlugin which no initial() defined but I define the function at derived class. 3. I can just put a abstract class in exe and no derived class provided? so if program in exe use the abstract class and what happen? i.e I have a abstact class in exe and dervied class in dll,but the dll is lost,and how to let the exe run without crash? [Edited by - luasitdown on August 18, 2005 5:57:27 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by vNistelrooy
This isn't a pure virtual functions so as long so you implement IPlugin::initial there should be no problems.


no ,look!

main(){}

class IPlugin
{
protected:
virtual void initial();
};


class A :public IPlugin
{
void initial(){}
};

IPlugin I;



the code not work. why?

Share this post


Link to post
Share on other sites
You need to add a function body to IPlugin's initial(). You can't have an abstract base class instantiated when it contains pure virtual functions or functions that haven't been implemented. If you need to use the base class then you shouldn't be making it abstract. Just give it's virtual functions empty bodies. Abstract base classes should only be used when you are certain you will not have any instances of it.

Share this post


Link to post
Share on other sites
Quote:
Original post by luasitdown
Quote:
Original post by vNistelrooy
This isn't a pure virtual functions so as long so you implement IPlugin::initial there should be no problems.


no ,look!
*** Source Snippet Removed ***

the code not work. why?


Because 'I' is not any particular *kind* of IPlugin. So which code should it call? All it can use is the base IPlugin code, but there isn't any.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!