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」中做的那樣做? 哪個更快?如何通過複製,通過派生類中的方法來設置基類字段?
謝謝大家的幫助:) – Opeww