I have a class called classBullet. It inherits another class that I've been using and have no problems with. I've been using classBullet without issue as well but when I try to pass a classBullet object by reference to another function I get this error :
void DrawBullet(classBullet *cBullet) //// <-- why is this giving me an error message?
{
}
void DrawBullets()
{
DrawBullet(&cPlayer.cBullet); // <--- pass object by reference
}
If I just use the classBullet object in the calling function and do all my work there it has no problem but suddenly, when I send it as a pointer, the IDE cries and gets all whiny about it.
??!?
why is this
Is the second code snippet in a .ino file (ie not a .cpp file) ?
If so, first suspect an unwanted prototype generation for function, in this case DrawBullet(), which can give rise to mysterious error messages.
If you can't fix it, show how this is declared: cPlayer.cBullet
I think something missing or extra ABOVE the "DrawBullet()" declaration is causing it to be treated as something other than a global function declaration. For example, a missing '}' on the previous declaration could do that.
thank you for your replies,
the code compiles and runs fine until I try to send the classBullet as a reference parameter, so I draw from that that there is no missing parentheses.
the alternate suggestion requested I show you how the cBullet is declared in classPlayer.
Try creating a function prototype like this and put it high up in the global definitions.
void DrawBullet(classBullet *cBullet) ;
to see if the error message goes away or changes.
In a .ino file, the Arduino builder of the IDE creates function prototypes to allow users to use resources before these are declared. It sometimes gets things in the wrong order causing misleading error messages. This could be the case here.