jerome
1
I am long time c, just starting c++, why doesn’t this compile?
I get ptr “does not name type” error.
#include "application.h"
class foo{
public:
int bar;
int barr;
};
foo myfoo;
foo *ptr;
ptr = &myfoo;
void setup(){
delay(1000);
}
void loop(){
delay(1000);
}
mdma
2
Change that to
foo *ptr = &myFoo;
The difference is that it's initialized as part of the declaration, while what you did was add some executable code outside of a function.
You could also have done:
setup()
{
ptr = &myfoo;
}
C/C++ isn't like javascript - you can't put executable code just anywhere! 
2 Likes
jerome
3
you’re awesome, and working late… Thanks
1 Like