About Store Forum Documentation Contact



Post Reply 
[SOLVED] Casting -> void is not a class error...
Author Message
Fluxor Offline
Member

Post: #1
[SOLVED] Casting -> void is not a class error...
So I have some problems with casting...

When casting
I always get a "**void is not a class**" error.

Code:
PickUp* pu = dynamic_cast<PickUp*>(actor.obj); // <-- ERROR!!

Interesting is that I found some older projects from other
people that used casting in a slightly different way, but for the same purpose.
So it likely worked at some time. But when building these now,
the same error pops up.

Like in this example:

Code:
if (Physics.ray(pos, dir * 10, &selector))
      {
         if(Kb.b(KB_L))
         {
            if (magicLamp * lamp = CAST(magicLamp, selector.obj)) // <--- ERROR!
            {
               lamp.selected = true;
            }
         }

Same error. Any idea what changed/went wrong?
As this looks to me like the very standart/typical way of downcasting, I have no idea
why this doesn't work as intended.


Same here, from Tottels TowerDefense Demo:
Code:
if(Physics.ray(start, end-start, &phys_hit, IndexToFlag(AG_TURRET))) // if ray hit the terrain
         {
            // Player left-clicked on the turret
            if(Turret* turret = CAST(Turret, phys_hit.obj)) // <-- ERROR!!
            {
               ResetAllMaterials(); // First, set all turrets unselected  

               turret->SetSelected(true);
               m_TurretGUI->SetDraw(true);
               m_TurretGUI->SetTurret(turret);
            }

and in quite a few more as well.. Kinda odd...


EDIT:
So reinterpret_cast does work...
Well, ok then...
(This post was last modified: 08-23-2021 02:22 AM by Fluxor.)
08-23-2021 01:46 AM
Find all posts by this user Quote this message in a reply
Post Reply