Can I have regular function and class function together? if so, where should i place the regular function declaration? The compiler wouldn't compile this one... the problem is function showlist() 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);
	
		//void addName(int, Name);

	};

	void showlist();
	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++;
		}

		cout<<"There are total "<<i<<" people in the list."<<endl;
		cout<<endl;
		
		for(int x=0; x<i; x++)
		{
		name[x].output();
		}
		*/
		
                showlist();
		
		

		return 0;
	}



	
	void showList()
	{
		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++;
		}

		cout<<"There are total "<<i<<" people in the list."<<endl;
		cout<<endl;
		
		for(int x=0; x<i; x++)
		{
		name[x].output();
		
		}
	}
	



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

What error does the compiler give? At first glance I can't see any problem with the code.

sorry,, it is actually a built error. however, does my program's syntax structure fine? This is my first time combining class function and regular function.

1>------ Build started: Project: lab1, Configuration: Debug Win32 ------
1>Linking...
1>lab1.obj : error LNK2001: unresolved external symbol "void __cdecl showlist(void)" (?showlist@@YAXXZ)
1>C:\Documents and Settings\lih\My Documents\Visual Studio 2005\Projects\lab1\Debug\lab1.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\lih\My Documents\Visual Studio 2005\Projects\lab1\lab1\Debug\BuildLog.htm"
1>lab1 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

There is a spelling mistake with the function name. showlist() and showList()

WolfPack beat me.

There is a spelling mistake with the function name. showlist() and showList()

god, i thought i would never make this kind of bug again....... thx so much

When you stop creating these kind of bugs you've stopped programming. Learning what type of problem the warnings and errors are pointing out takes time. Keep consistent with your naming protocols and this type of problem will decrease in frequency.

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.