First of all, i hope the
thing is what i was asked to do to encase the my code.
And please help on the set() function. I don't know why the string type in the parenthesis gave me compile error undeclared identifier. thank you.
# include <iostream>
# include <string>
# include <fstream>
using namespace std;
class Name
{
public:
int id;
string lastName;
string firstName;
string phone;
double amt;
void output();
void set(int, string, string, string, double);
};
int main()
{
Name name[300];
ifstream reader;
reader.open("names.txt");
int i=0;
while(reader>>name[i].id>>name[i].lastName>>name[i].firstName>>name[i].phone>>name[i].amt)
{
i++;
}
name[0].set(123, aLastName, aFirstName, 617-538-2888, 1000.00);
/*
for(int x=i-1; x>-1; x--)
{
name[x].output();
}
*/
return 0;
}
void Name::output()
{
cout<<id<<" "<<lastName<<" "<<firstName<<" "<<phone<<" "<<amt<<endl;
}
void Name::set(int inputID, string inputLastName, string inputFirstName, string inputPhone, double inputAmount)
{
id= inputID;
lastName = inputLastName;
firstName = inputFirstName;
phone= inputPhone;
amt = inputAmount;
}