I want to make it so my program will create an object based on user input. When I run the program I get the error "identifier "plant" is undefined" on the first call of plant which is "while(plant.getDays() > 0){".
#include "Carrot.h"
#include "Potato.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
int gameState = 1;
cout << "WELCOME TO THE CROP GAME" << endl;
while(gameState == 1){
cout << endl << "PICK A CROP TO GROW" << endl;
cout << "1:CARROT - SHORT" << endl;
cout << "2:POTATO - LONG" << endl;
int userGameChoice;
cin >> userGameChoice;
while(userGameChoice < 1 || userGameChoice > 2){
if(userGameChoice == 1){
Carrot plant;
cout << "YOU HAVE CHOSEN TO GROW CARROTS" << endl;
}
else if(userGameChoice == 2){
Potato plant;
cout << "YOU HAVE CHOSEN TO GROW POTATOES" << endl;
}
else{
cout << "INVALID CHOICE" << endl;
cin >> userGameChoice;
}
}
while(plant.getDays() > 0){
int userChoice;
//STATS
plant.DisplayStats();
//MENU
plant.Menu();