Home » Community » Newbie corner » |SOLVED] Vector of object: cast to inherited class
|SOLVED] Vector of object: cast to inherited class [message #52353] |
Fri, 13 September 2019 16:32  |
 |
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Hello,
Is it possible to do something like that :
#include <Core/Core.h>
using namespace Upp;
class A : public Moveable<A>{
public:
A(){}
virtual void Hello(){
Cout() << "Hello from A" <<"\n";
}
};
class B :public A, public Moveable<B>{
public:
B(){}
void Hello(){
Cout() << "Hello from B" <<"\n";
}
};
CONSOLE_APP_MAIN
{
Vector<A> myVector;
static_cast<B&>(myVector.Add()).Hello();
//Looking for "Hello from B"
}
Without using Vector of ptr or reference ?
Thanks in advance
Best regard.
[Updated on: Sun, 15 September 2019 12:53] Report message to a moderator
|
|
|
 |
|
|SOLVED] Vector of object: cast to inherited class
By: Xemuth on Fri, 13 September 2019 16:32
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Fri, 13 September 2019 21:55
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sat, 14 September 2019 00:29
|
 |
|
Re: Vector of object: cast to inherited class
By: Xemuth on Sat, 14 September 2019 13:41
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sat, 14 September 2019 21:39
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sat, 14 September 2019 21:45
|
 |
|
Re: Vector of object: cast to inherited class
By: Xemuth on Sun, 15 September 2019 12:52
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sun, 15 September 2019 17:31
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sun, 15 September 2019 17:54
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Mon, 16 September 2019 09:35
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 16:29
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 16:31
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Mon, 16 September 2019 16:47
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 17:44
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Mon, 16 September 2019 20:02
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 20:09
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Mon, 16 September 2019 20:25
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 23:47
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Tue, 17 September 2019 09:55
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Tue, 17 September 2019 14:11
|
Goto Forum:
Current Time: Tue May 13 18:03:30 CEST 2025
Total time taken to generate the page: 0.03563 seconds
|