I'm new to c++, coming from python.
I'm working on a ray tracer program, that can loop over a list of objects in the scene.
this "pseudo-code", which i know is not working, will illustrate what i want to do:
class A{public:
int i;
//methods
};
class B{public:
int i;
//methods
};
void f(MyType objs[]){
for( MyType ob : objs){
//do somthing to ob's members
}
}
int main(){
A a1,a2,a3;
B b1,b2;
//i don't now how but i want to create
//an array that contains a different
//instances of different
//typs A, B and C...
MyType objects[]=[a1,a2,a3,b1,b2];
//and lastly i want to pass the array to my function
f(objects);
return 0;}
i tried to create a base class and make A and B inherent classes. how can i do that or is that simply impossible? , and if so how i can achieve similar result.