class Base{
public:
float a,b;
};
class Derived:public Base{
public:
int someInteger, otherInt;
void assignNthElement(vector<Base> &myArray,int i){
this=myArray[i-1];//??? How ???
}
void simpleMethodOfAssigningNthElement(vector<Base>&myArray,int i){
a=myArray[i-1].a;
b=myArray[i-1].b;
}
};
如何从 myArray 直接复制描述派生类中基类的值?也许最好像在“simpleMethodOfAssigningNthElement”中那样做?哪个更快?