S
Student911
Hello,
I read that upward casting is always safe but downward casting/
For example:
Derived* p=(Derived*) new Base();
casting can cause problems with the memory. Can someone please give me
an example that memory problems are caused?
I thought that problems will happen during upward casting since if
Person has _name and _id and programmer is derived from person and has
_company is another member then the casting:
Person *p= new Programmer("Greg Smith",954954,Intel);
Then this casting will cause the lost of the _company member, but I was
told it won't happen. Can someone explain that as well?
Thanks in advance
I read that upward casting is always safe but downward casting/
For example:
Derived* p=(Derived*) new Base();
casting can cause problems with the memory. Can someone please give me
an example that memory problems are caused?
I thought that problems will happen during upward casting since if
Person has _name and _id and programmer is derived from person and has
_company is another member then the casting:
Person *p= new Programmer("Greg Smith",954954,Intel);
Then this casting will cause the lost of the _company member, but I was
told it won't happen. Can someone explain that as well?
Thanks in advance