Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
cannot dynamic_cast 't' (of type 'void*') to type 'struct mom::object*' (source is not a pointer to
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Alipha, post: 2517110"] yes. you can't cast from void* because the compiler can't know what type the object really is. you can only cast from polymorphic types (in which case, the compiler typically looks at the v-table pointer to determine what type the object really is). void construct(void * t); void construct(object * t); problem solved? the cast is completely unnecessary, T* converts to void* implicitly, where T is not a function or member function type. of course, if you convert to void*, you lose all type info, which probably isn't a good thing. you might want to consider boost::any, however that probably won't help with your overall design. [URL="http://www.boost.org"]www.boost.org[/URL] quite frankly, any program design which includes such an incredibly generic object base class usually smells of a bad design. you can't do anything with this object other than construct or destroy it. you'd have to cast to a more specific derived class type to do anything useful with it, which trying to figure out what derived class to cast to is generally a "fun" exercise. C++ doesn't have an object base class for a reason. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
cannot dynamic_cast 't' (of type 'void*') to type 'struct mom::object*' (source is not a pointer to
Top