0

Hi All

I was going through a code and came across something like -->

TC_A &tc_a=*(TC_A *)p;

Now TC_A is a derived class of another Class 'X' of which p is an instance.
Does this mean that a new class instance of TC_A is invoked and contents of p copied onto it ?

Can i replace it with

TC_A *tc_a = new TC_A;
tc_a=(TC_A)p;

It would be great if someone could help me understand as to what this code actually does.


Best Regards
Varun

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by gpta_varun
-1

No, notice the & sign before tc_a? This means tc_a is a reference.
So tc_a will reference p, which essentially makes them one and the same object.

Have you ever used references in function parameters? If not.. this is a good time to read about it ;)

0

No, notice the & sign before tc_a? This means tc_a is a reference.
So tc_a will reference p, which essentially makes them one and the same object.

Have you ever used references in function parameters? If not.. this is a good time to read about it ;)

Thanks :) !!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.