Okay, so I need to have a program setup so that people can enter in a user's first name and last name, hours and salary. They need to be able to keep entering in data until they decide they are done. Then, they need to be able to recall the information. I can get it to work with 1 employee, but I don't know how to have it automatically create the objects (each object is an employee). Here is what I have:
I know the way is to use pointers...but I don't know how. I followed the link and read up on it, but I need more coding examples and that did not make a whole lot of sense to me... Any other ideas?
#include <iostream>
#include <vector> //for vectors
class Obj {
int data;
public:
void set_data(intnew) { this->data = new; }
int get_data() { returnthis->data; }
}
int main() {
std::vector<Obj> objects; //this makes a vector of objects
Obj my_new_obj;
my_new_obj.set_data(5); //make and set a new object
objects.push_back(Obj); //add the object to the vector
//...
for(unsignedint i = 0; i < objects.size(); ++i) { //loop through the vector
std::cout<<"Obj "<<i<<" has "<<objects[i].get_data()<<"\n"; //print out the info
}
}