how to swap two different class objects using void pointers in c++
hai
i have class A and Class B along with two objects
A a1;
B b1;
(void *)
so i want to swap two objects using void pointer
Can anyone help me...do the needful asap
Re: how to swap two different class objects using void pointers in c++
What do you mean with swap? swap what?
What is the situation you want to arrive at?
Cheers,
_
Re: how to swap two different class objects using void pointers in c++
You mean you want to do something like this?
Code:
A * a = new A();
B * b = new B();
A * c = (A *)( void * )b;
You might be able to fool the compiler into accepting code like that, but what do you think will happen when you try to execute a member function of class A when the variable c actually points to an instance of class B?