S
Sree
If class B derives from class A and we create an array of class B like
B *arrayOfB = new B[10]; and
// Instance of A
A firstInstanceOfA;
How can we store firstInstanceOfA in arrayOfB ? I tried the following way
arrayOfB[0] = firstInstanceOfA;
arrayOfB[0] = (B*)firstInstanceOfA;
Both the ways doesn't seems to work, also if we need to reverse the way of
assigning, like
A *arrayOfA = new A[10];
and we need to store instance of B what has to be done ?
Thanks in Advance
Ik
B *arrayOfB = new B[10]; and
// Instance of A
A firstInstanceOfA;
How can we store firstInstanceOfA in arrayOfB ? I tried the following way
arrayOfB[0] = firstInstanceOfA;
arrayOfB[0] = (B*)firstInstanceOfA;
Both the ways doesn't seems to work, also if we need to reverse the way of
assigning, like
A *arrayOfA = new A[10];
and we need to store instance of B what has to be done ?
Thanks in Advance
Ik