首页 > 试题广场 >

用包含方式改写以上习题中的Vector类,使其实现相同的功能

[问答题]
使用Integer类,定义派生类Vector类:
class Integer
{   //…
    protected :
    int n;
};
class Vector:public Integer
{   //…
    protected :
    int v;
};
其中,数据成员v用于建立向量,n为向量长度。

用包含方式改写以上的Vector类,使其实现相同的功能。
class Vector
{ //…
    protected :
    Integer v;
    Integer size;
};


这道题你会答吗?花几分钟告诉大家答案吧!