虚函数和纯虚函数链接库的区别

1.纯虚函数
virtual CMsvOperation* CancelL(TRequestStatus& aStatus, const CMsvEntrySelection& aSelection) = 0;

只提供一个接口,靠继承类实现定义。个人理解:symbian导出类函数在freeze时将生成def文件,而pure virtual函数无法生成这样的导出定义。纯虚函数一般作为接口类使用,无所谓导出与否。接口类一般都通过工厂函数来进行实例化。所以不需要使用export_c和import_c关键字

 

2. 虚函数
父类和子类都有这个函数的实现。需要在头文件中的函数前加“IMPORT_C”关键字, 在源文件中加EXPORT_C关键字

虚函数是运行的时候绑定的。这个意味着: 应用程序(.exe)在运行的时候,才链接相应的库地址。即所需链接的函数地址开始并不知晓。 所以如果应用程序A依赖库B,库B中的函数是虚函数,很多的实现依赖继承自库B的库:库c。 则A在链接库的时候,只需要连接B库就行了。 但如果A调用的函数是库c的函数,而且这个函数没在库B中未被声明为虚函数。则库A必须链接库c,才能找到相应的函数符号。

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

No related posts.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Contact us

Admin: Bryan Wu