cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
GNU C++: can i get the derived class poi
GNU C++: can i get the derived class pointer on base class?
May 27, 2018 at 1:15pm UTC
Cambalinho
(1445)
i'm on base class. can i get the derived\child class pointer without using it on constructor argument?
May 27, 2018 at 4:21pm UTC
keskiverto
(10402)
You have to explain the goal a bit more.
As is the question makes little sense, because a base class is not supposed to know nor care whether anything derives from it (although abstract classes can bet that something does).
May 27, 2018 at 8:33pm UTC
coder777
(8444)
Use
dynamic_cast
<derived *>(...)
. See:
http://en.cppreference.com/w/cpp/language/dynamic_cast
http://www.cplusplus.com/doc/tutorial/typecasting/
Topic archived. No new replies allowed.