user7117046 user7117046 - 7 months ago 87
C++ Question

Eclipse IDE Arduino (Sloeber) C++ String in class error does not name a type

In the project

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 {
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
instead of quotes and with without the
I'm totally confused. Thanks.


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.