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;
	}

>name[0].set(123, aLastName, aFirstName, 617-538-2888, 1000.00);
You haven't declared aLastName or aFirstName.

>617-538-2888
That's totally not doing what you think it's doing. :D

Line 33. You have numbers representing a phone number there. They need to be in double quotes to be recognized as a string and not the literal value

Not certain why you had to start another thread either. Basically the same problem as last time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.