cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Cast
Cast
Mar 14, 2014 at 9:58am UTC
Alby94
(63)
Why can not I convert the object of a derived class to a base class without using pointers?
1
2
3
4
5
6
7
Derived o; Base i = (Base)o;
/*/ Error /*/
Derived* o; Base* i = (Base*)o;
/*/ Ok /*/
Mar 14, 2014 at 10:07am UTC
Peter87
(11234)
It should "work" if you have used public inheritance and you have not disabled the copy/move constructors.
Mar 14, 2014 at 12:12pm UTC
MikeyBoy
(5631)
Duplicate of
http://www.cplusplus.com/forum/beginner/126132/
. Please don't spam the forum with multiple threads for the same topic.
Topic archived. No new replies allowed.