A
Alexander Adam
Hi all!
Not sure what I am doing wrong so someone might be able to help me out
here. I have a class model which looks like this:
struct A
{
...
};
struct B : public A
{
...
}
Now I have a simple function which looks like this:
A DoSomething()
{
return B(....);
}
And I am trying to cast it back to B from the outside:
....
A myClass = DoSomething();
B myClass2 = .... ??????
I've tried dynamic_cast etc. but it doesn't seem to work. What I am
doing wrong here? I'd like to avoid using dynamic_cast as I would like
to avoid having to use pointers (i.e. return A* instead of A).
Any idea?
thanks!
Alex
Not sure what I am doing wrong so someone might be able to help me out
here. I have a class model which looks like this:
struct A
{
...
};
struct B : public A
{
...
}
Now I have a simple function which looks like this:
A DoSomething()
{
return B(....);
}
And I am trying to cast it back to B from the outside:
....
A myClass = DoSomething();
B myClass2 = .... ??????
I've tried dynamic_cast etc. but it doesn't seem to work. What I am
doing wrong here? I'd like to avoid using dynamic_cast as I would like
to avoid having to use pointers (i.e. return A* instead of A).
Any idea?
thanks!
Alex