I boiled some code of my Arduino Project down to this:
#include <iostream>
class myClass {
public:
int foo;
myClass() {foo = 3;};
};
myClass * f_dummy() {
myClass * ptr_ret;
ptr_ret = new myClass;
return ptr_ret;
};
int main() {
myClass * ptr_class;
ptr_class = f_dummy();
std::cout << ptr_class->foo;
delete ptr_class;
}
Basically, i want to create a new instance of myClass in f_dummy() and return its Pointer. http://cpp.sh seems not to have problems with compiling and running this. (I get "3" on the console) The Arduino IDE on the other hand gives me a compiler error: error: expected constructor, destructor, or type conversion before '*' token
I wonder why these two compilers behave different in this case and if there is a way to get my code to work in the arduino IDE. (I'm new to C++)