This is code that is giving me trouble:
Code:
int main(void) {
const char Off[] = "Off";
Sensor *X = new Sensor("On", "near the front door");
MainFrame *W = new MainFrame("Off");
cout << "Sensor X is located " << X->GetLocation() << endl;
cout << "Sensor X is currently " << X->GetSensorState() << endl;
The output from this code should be:
Sensor X is located near the front door (this works)
Sensor X is currently On
Instead I get:
Sensor X is located near the front door
Sensor X is currently Onnear the front door
This is the function GetSensorState:
Code:
inline char *GetSensorState() { return State; }
All it does is return State which is a protected character array. State is defined as
char State[2] (only meant to hold 'On' or 'Off' so i figured 2 is enough)
The function GetLocation is:
Code:
inline char *GetLocation() { return itsLocation; }
All GetLocation does is return itsLocation which is a protected character array that describes the location of the sensor
itsLocation is defined as:
char itsLocation[50];
I am honestly not sure what is wrong here, this is quite strange.