Getting Strings into my library

Hello all, I'm writing a library that will control temperature and humidity or anything of the like. I'm getting "error: 'String' does not name a type" so I believe that I'm not including String.h correctly in Controller.cpp

If anyone could help me out and explain what I'm doing wrong I would really appreciate it. :grin:

Controller.h:

// Controller.h

class Controller
{
	public:
	Controller(int devicePin, int turnPoint, int leeway, bool inverted, char deviceName[16], char controlLabel[12]);
	
	void CheckController(int reading);
	bool State();
	String DeviceName();
	String ControlLabel();
	
	private:
	int _devicePin;
	int _turnPoint;
	int _leeway;
	bool _inverted;
	bool _state;
	char _deviceName[16];
	char _controlLabel[12];
};

class DualController
{
	public:
	DualController(int lowDevicePin, int highDevicePin,
		int lowTurnPoint, int highTurnPoint, char lowDeviceName[16],
		char highDeviceName[16], char controlLabel[12]);

	void CheckController(int reading);
	bool LowState();
	bool HighState();
	String HighDeviceName();
	String LowDeviceName();
	String ControlLabel();

	private:
	int _lowDevicePin;
	int _highDevicePin;
	int _lowTurnPoint;
	int _highTurnPoint;
	bool _lowState;
	bool _highState;
	char _lowDeviceName[16];
	char _highDeviceName[16];
	char _controlLabel[12];
};

Controller.cpp:

// Controller.cpp

#include <String.h>
#include "WProgram.h"
#include "Controller.h"
 
Controller::Controller(int devicePin, int turnPoint, int leeway, bool inverted, String deviceName, String controlLabel)
{
	pinMode(devicePin, OUTPUT);
	_devicePin = devicePin;
	_turnPoint = turnPoint;
	_leeway = leeway;
	_state = false;
	_inverted = inverted;
	
	deviceName.toCharArray(_deviceName, 16);
	controlLabel.toCharArray(_controlLabel, 12);
}

Controller::CheckController(int reading)
{
	if(_inverted)
	{
		if(reading<=_turnPoint && !state)
		{
			digitalWrite(_devicePin, HIGH);
			_state = true;
		}
		else
		{
			if(_state && reading >= (_turnPoint + leeway)
			{
				digitalWrite(_devicePin, LOW);
				_state = false;
			}
		}
	}
	else
	{
		if(reading>=turnPoint && !state)
		{
			digitalWrite(_devicePin, HIGH);
			_state = true;
		}
		else
		{
			if(reading <= (_turnPoint - 5) &&_state)
			{
				digitalWrite(_devicePin, LOW);
				state = false;
			}
		}
	}
}

Controller::State()
{
	return _state;
}

Controller::DeviceName()
{
	return String(_deviceName);
}

Controller::ControlLabel()
{
	return String(_controlLabel);
}

DualController::DualController(int lowDevicePin, int highDevicePin,
	int lowTurnPoint, int highTurnPoint, char lowDeviceName[16],
	char highDeviceName[16], char controlLabel[12])
{
	if(reading<=_lowTurnPoint && !lowState)
	{
		digitalWrite(_lowDevicePin, HIGH);
		_lowState = true;
	}
	else
	{
		if(_lowState && reading >= (_lowTurnPoint + leeway)
		{
			digitalWrite(_lowDevicePin, LOW);
			_lowState = false;
		}
	}
	
	if(reading>=_highTurnPoint && !_highState)
	{
		digitalWrite(_highDevicePin, HIGH);
		_highState = true;
	}
	else
	{
		if(reading <= (_highTurnPoint - 5) &&_highState)
		{
			digitalWrite(_highDevicePin, LOW);
			_highState = false;
		}
	}
}

DualController::LowState()
{
	return _lowState;
}

DualController::HighState()
{
	return _highState;
}

DualController::LowDeviceName()
{
	return String(_lowDeviceName)
}
	
DualController::HighDeviceName()
{
	return String(_highDeviceName);
}

DualController::ControlLabel()
{
	return String(_controlLabel)
}

Include 'String.h' in the header instead of the .cpp

your controller class declaration (.h) declares objects of type String but String's are unknown and not included till the cpp file.

Thanks Pyro_65! XD, I'll try it out as soon as I get back to my pc.

Better yet, quit using Strings. The internal storage is a char array. Why waste the resources needed to wrap a copy of that array in a String object. Just return a pointer to that array. Make the pointer const if you don't want the caller to be able to change the array.