-
May 21st, 2009, 06:32 PM
#1
Struct inheritance
Alright, simple problem, hopefully simple solution.
This is going to seem like a stupid question, I know but I'm having some difficulty with struct inheritance.
Here's what I have:
struct A
{
//elements here
}
struct B:A
{
//more elements here
}
int main(void)
{
A* pa = new B();
B* pb;
pb = pa;//this is the important part
return 0;
}
Do I need an explicit cast here?
Also, say I was trying to do:
A a;
B b;
b = a;
Do I need a new constructor B(A a) in B to handle this or is there another way?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|