So I have an array of Object pointers, which can be one of two different classes derived from Object. Object has a virtual function, intersect, which in Object has no parameters, but in both the derived classes have the same parameters, just different implementations. I want to be able to go down the array, calling intersect each time without having to worry about checking which class it is.
Problem is that whenever I try to call the intersect function I get "No matching function for call", and it says that it expects 0 arguments instead of the 4 in the derived classes. I try to make it into a pure virtual function in the base, but since I can't have an array of pointers to an abstract class, that doesn't work. I look it up on Stack overflow and the only thing that I can get results on is name hiding, but that seems to come from people trying to use the method in the base class. Still tried the recommended solution of inserting "using base: method", but that doesn't do anything, again.
Basic structure is-
class Object
{
public:
virtual int intersect() {};
}
class thing: public Object
{
public:
int intersect(double, double, double, double)
}
class thing2: public Object
{
public:
int intersect(double, double, double, double)
}
obj = new Object*[numObj]
tempThing = new thing();
obj[0] = tempThing;
obj[0]->intersect(double, double, double, double);