Reputation: 45
In the project .ino
file this works:
void loop()
{
String stringOne = "Hello String";
}
However, in a class I get these errors:
// MenuItem.h
//#include "String.h" ====> Makes no difference if not commented
class MenuItem {
public:
MenuItem();
private:
String stringTwo; ====> 'String' does not name a type
};
// MenuItem.cpp
//#include "String.h" ====> Makes no difference if not commented
MenuItem::MenuItem() {
stringTwo = "Goodbye String"; ===> 'stringTwo' was not declared in this scope
}
I've tried different option for the #include
with <>
instead of quotes and with without the .h.
I'm totally confused. Thanks.
Upvotes: 1
Views: 730
Reputation: 1594
The String class for Arduino is held in the WString.h and WString.cpp files.
You should just include WString.h in your .h file. The Arduino IDE automatically does this for your .ino files.
Upvotes: 1