Is there a way for me to add a variable to a local variables name? i.e
cout << "YOU HAVE SELECTED EMPLOYEE" << "employee & WhatEmployeeIsEdit".getname();
I have tried
"employee & WhatEmployeeIsEdit"
"employee + WhatEmployeeIsEdit"
and with my extremely limited coding vocabulary searching W3 has been very difficult. I have no coding experience whatsoever so I apologize if this is an improper question or has been asked elsewhere. The complete code is as follows :
#include<iostream>
#include<cmath>
#include "Learning.h"
using namespace std; // this makes it so you dont have to type STD:: every time you want to c out or in
class Employee { //rem class has attributes and behaviors
private: // rem unless its specifically public or protected, its private
//classes like this do not have any data in them, instead they serve as a bluprint for all "employee"s that are made
string Name; /// this is a variable declraration
string Company;
int Age;
public:// implied priavte if not stated, but reccomended to make it clear
void setName(string name) { // name getter
Name = name;
}
void setCompany(string company) { // company getter
Company = company;
}
void setAge(int age) { // age getter
Age = age;
}
string getName() { ///name setter
return Name;
}
string getCompany() { ///Company setter
return Company;
}
int getAge() { ///age setter
return Age;
}
void SayHI() { /// this is a function of the class employee
cout<< "Name - " << Name << "\n Company - " << Company << "\n Age - " << Age << "\n\n -------------------------------------------------\n";
}
Employee(string name, string company, int age) { // this is the constructor, note that it is inside the class, and public but outside of all functions
Name = name;
Company = company;
Age = age;
}
};
int main() {
//Employee employee1; //these definitions are only avalible if attributes are set to public
//employee1.Name = "joe";
//employee1.Company = "WGU";
//employee1.Age = 29;
//employee1.SayHI();
//Employee employee2;
//employee2.Name = "Nate";
//employee2.Company = "St.T";
//employee2.Age = 22;
Employee employee1 = Employee("Ray", "Enviormentalist", 23);
employee1.SayHI();
Employee employee4 = Employee("Anna", "Stay at home", 28);
employee4.SayHI();
employee1.setAge(33);
//std::cout << employee1.getName() << " is " << employee1.getAge() << " years old" <<"\n";
int WhatUserWantsToDo;
int WhatEmployeeIsEdit;
cout << employee1.getName() << " is " << employee1.getAge() << " years old " << endl;
cout << "WHAT DO YOU WANT TO DO? \n - Age =1\n - Company =2";
cin >> WhatUserWantsToDo;
if (WhatUserWantsToDo == 1) {
cout << "WHAT EMPLOYEE DO YOU WANT TO EDIT? \n 1 \n 2";
cin >> WhatEmployeeIsEdit;
cout << "YOU HAVE SELECTED EMPLOYEE" << "employee & WhatEmployeeIsEdit".getname();
if (WhatEmployeeIsEdit == 1) // possible to make if whatEmployeeIsEdit == search for matching employee number?
// then ask for new employee age
//then print employee name is X years old
} if {
//if they chose 2, goto select employee, then prompt for new complany name, and print employee name's new company is x
}
else {
cout >> "SORRY, PLEASE CHOOSE ONE OF THE SUGGESTED VALUES"
} // maybe add back button? so you dont have to re-run the program each time?
// how dose program hold data between runs?
//save function?
return 0
} // end main