在没有动手实验之前确实这个问题不能确定,我在理论中想象是否定的(或许你也是这样的想法),但事实告诉我们是可以的。
这是main中的测试代码:
在这之后我会提供给大家整个测试源代码。
#include "stdafx.h"
//#include<iostream>
//using namespace std;
#pragma comment(lib,"test.lib")//链接库文件
class drifirst :public frist
{
public:
int show(int i)
{
// frist.show(3);
printf("%s/n","test");
;//cout<<"派生"<<endl
return 0;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
frist *fp;
drifirst *fb=new drifirst;
fp=fb;
fp->show(2);
fb->show(1);
return 0;
}
这个问题还是超越了个人的想象,实践看来是更有效,更真实的做法。
程序代码:http://download.youkuaiyun.com/source/3273031 (包含lib库,及头文件等)
本文通过实践证明,静态库(Lib)中的类可以被另一个工程的类继承,并且其方法可以被覆盖。作者提供了测试代码,展示了一个派生类如何继承库中类并重写其方法,强调了实践在解决这类问题中的重要性。
6万+

被折叠的 条评论
为什么被折叠?



