EDIT: final version using const references :-)
///Test-code. place anywhere in global C++ scope for testing
class A;
class B;
class Base{
public:
virtual void DoSomething ( const A & object1, const B & object2) = 0;
};
class A: public Base{
public:
void DoSomething(const A & object1, const B & object2) {
int i=0;
i++; //test break point
};
};
class B: public Base{
public:
void DoSomething(const A & object1, const B & object2) {
int i=0;
i++; //test break point
};
};
bool test()
{
A a;
B b;
a.DoSomething( A(), B() );
b.DoSomething( A(), B() );
return true;
}
static bool invokeTest = test();
///END of test-code
EDIT: better version using auto_ptr
///Test-code. place anywhere in global C++ scope for testing
#include <memory>
using std::auto_ptr;
class A;
class B;
class Base{
public:
virtual void DoSomething (auto_ptr<A> object1, auto_ptr<B> object2) = 0;
};
class A: public Base{
public:
void DoSomething(auto_ptr<A> x, auto_ptr<B> y) {
int i=0;
i++; //test break point
};
};
class B: public Base{
public:
void DoSomething(auto_ptr<A> x, auto_ptr<B> y) {
int i=0;
i++; //test break point
};
};
bool test()
{
Base *a = new A;
Base *b = new B;
a->DoSomething( auto_ptr<A>(new A), auto_ptr<B>(new B) );
b->DoSomething( auto_ptr<A>(new A), auto_ptr<B>(new B) );
return true;
}
static bool invokeTest = test();
///END of test-code
Original answer
If the arguments are pointers, then it should work:
class A;
class B;
class Base{
public:
virtual void DoSomething (A * object1, B * object2) = 0;
};
class A: public Base{
public:
void DoSomething(A *x, B *y) {
};
};
class B: public Base{
public:
void DoSomething(A *x, B *y) {
};
};
P.S.:I wonder why you would need it?
EDIT P.P.S.: I still wonder why one would need it :-)?