我有这个功能
# include "Rectangle.hh"
# include "Circle.hh"
void inst_obj (int symbols) {
for (int i=0; i<symbols ; i++) {
if (i<10) {
Rectangle symb(1,2,3);
//Store symb in an array, like symb_array[i] = symb;
}
else {
Circle symb(1,2,3,4);
//Store symb in an array, like symb_array[i] = symb;
}
}// inst_obj
然后我有另一个功能:
void check_symbols(symbols) {
for (int i=0; i<symbols; i++) {
// Check symbol objects, like symb_array[i].return_something
}
} // check_symbols
如何以简单的方式存储指向不同对象的指针?(然后你如何访问它们)?