Hello!
I am a little stuck, I need to create a array of objects (class) and seem to having some troubles.
I will only post up my main file hopefully it will be enough.
You can see I have an array of object plant, when I compile with the header file and cpp, I get "left of '.plantName' must have class/struct/union type" errors on all my variables. I think I have a problem with my constructor maybe..
thankyou in advance.
[code=cpp]
#include <iostream>
#include <string>
#include "nursery.h"
using namespace std;
int main()
{
int selection = 0;
int i = 0;
Nursery plant[10];
plant[i].menu();
cin >> selection;
while (selection != 4)
{
switch (selection)
{
case 1: plant[i].addPlant();
break;
case 2: plant[i].waterPlant();
break;
case 3: plant[i].movePlant();
break;
case 4: // exit
break;
default: cout << "Illegal menu selection" << endl;
}
};
system ("pause");
}[/code]
I am a little stuck, I need to create a array of objects (class) and seem to having some troubles.
I will only post up my main file hopefully it will be enough.
You can see I have an array of object plant, when I compile with the header file and cpp, I get "left of '.plantName' must have class/struct/union type" errors on all my variables. I think I have a problem with my constructor maybe..
thankyou in advance.
[code=cpp]
#include <iostream>
#include <string>
#include "nursery.h"
using namespace std;
int main()
{
int selection = 0;
int i = 0;
Nursery plant[10];
plant[i].menu();
cin >> selection;
while (selection != 4)
{
switch (selection)
{
case 1: plant[i].addPlant();
break;
case 2: plant[i].waterPlant();
break;
case 3: plant[i].movePlant();
break;
case 4: // exit
break;
default: cout << "Illegal menu selection" << endl;
}
};
system ("pause");
}[/code]
Comment