hey everyone,

so im trying hard to get this assignment done by tomorrow but after sucessfully compiling, I am now getting linker errors. I have to use Vi for this assignment but never the less here are my linker errors:

assign5.o: In function `main':
assign5.cpp:(.text+0x1026): undefined reference to `Print(cStudent (&) [30], int)'
assign5.cpp:(.text+0x103d): undefined reference to `Display(cStudent (&) [30], int)'
collect2: ld returned 1 exit status


here is the code itself:

//assignment 5

#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;

const int NAMESIZE=11;
const int FILENAMESIZE=51;
const int ARRAYSIZE=20;
int N=0;
typedef char Name_t[NAMESIZE];
typedef int Grade_t;
typedef char Filename_t[FILENAMESIZE];
typedef fstream Infile_t;
typedef fstream Outfile_t;

class cStudent
{
	private:
		Name_t fname;
		Name_t lname;
		Grade_t t1;
		Grade_t t2;
		Grade_t t3;
		Grade_t t4;
		Grade_t ag;
		Grade_t eg;
	public:
		cStudent();
		cStudent(Name_t NewName, Grade_t NewGrade);
		//set
		void set_fname(Name_t first)
		{ strcpy(fname,first);}
		void set_lname(Name_t last)
		{ strcpy(lname,last);}
		void set_t1(Grade_t a)
		{ t1=a;}
		void set_t2(Grade_t b)
		{ t2=b;}
		void set_t3(Grade_t c)
		{ t3=c;}
		void set_t4(Grade_t d)
		{ t4=d;}
		void set_ag(Grade_t e)
		{ ag=e;}
		void set_eg(Grade_t f)
		{ eg=f;}
		//get
		void get_fname(Name_t &fname)
		{ strcpy(fname,this->fname);}
		void get_lname(Name_t &lname)
		{ strcpy(lname,this->lname);}
		int get_t1(Grade_t &t1)
		{ t1=this->t1; return t1;}
		int get_t2(Grade_t &t2)
		{ t2=this->t2; return t2;}
		int get_t3(Grade_t &t3)
		{ t3=this->t3; return t3;}
		int get_t4(Grade_t &t4)
		{ t4=this->t4; return t4;}
		int get_ag(Grade_t &ag)
		{ ag=this->ag; return ag;}
		int get_eg(Grade_t &eg)
		{ eg=this->eg; return eg;}
};// end class cStudent
//cStudent Methods
cStudent::cStudent()
{
	t1=0;
	t2=0;
	t3=0;
	t4=0;
	ag=0;
	eg=0;
};//end of cStudent::cStudent

typedef cStudent StudentArray[30];
StudentArray CSCI208Class; //array of cStudent objects

void Read(StudentArray &CSCI208Class, int &N);
void Sort(StudentArray &CSCI208Class, int &N);
void Print(StudentArray &CSCI208Class, int N);
void Display(StudentArray &CSCI208Class, int N);

//begin main
int main()
{
	Read(CSCI208Class,N);
	Sort(CSCI208Class,N);
	Print(CSCI208Class,N);
	Display(CSCI208Class,N);

	cout<<"TERMINATING PROGRAM.........GOODBYE!"<<endl;
	return 0;

};//end main

void Read(StudentArray &CSCI208Class, int &N)
{
	Filename_t Filename;
	Infile_t Infile;
	cout<<"Enter the name of the data file:"<<endl<<endl;
	cin>>Filename;
	cout<<"Opening Datafile..............."<<endl;
	Infile.open(Filename,ios::in);

	Name_t first, last;
	Grade_t a,b,c,d,e,f;
	N=0;

	Infile>>first;
	CSCI208Class[N].set_fname(first);
	while(!Infile.eof())
	{
		Infile>>last>>a>>b>>c>>d>>e>>f;
		CSCI208Class[N].set_lname(last);
		CSCI208Class[N].set_t1(a);
		CSCI208Class[N].set_t2(b);
		CSCI208Class[N].set_t3(c);
		CSCI208Class[N].set_t4(d);
		CSCI208Class[N].set_ag(e);
		CSCI208Class[N].set_eg(f);
		N=N+1;
		Infile>>first;
		CSCI208Class[N].set_fname(first);
	}//end while loop
	cout<<"READ COMPLETE..............."<<endl;
	cout<<"Closing Datafile..............."<<endl;
	cout<<"Begining Next Process..............."<<endl<<endl;
	Infile.close();
};//end of read

void Sort(StudentArray &CSCI208Class, int &N)
{
	int I,Pass;
	Name_t lname;
	Name_t nextlname;	
	for(Pass=0; Pass<N-2; Pass++)
	{
		for(I=0; I<N-2; I++)
		{
			CSCI208Class[I].get_lname(lname);
			CSCI208Class[I+1].get_lname(nextlname);
			if(strcmp(lname,nextlname)>0)
			{
				StudentArray Temp;
				Temp[I]=CSCI208Class[I];
				CSCI208Class[I]=CSCI208Class[I+1];
				CSCI208Class[I+1]=Temp[I];
			}//end if
		}//end inside for
	}//end outside for
};//end sort
	

void Print(StudentArray CSCI208Class, int N)
{
	Filename_t Filename;
	Outfile_t Outfile;
	cout<<"Please enter the name of the output file to be created:"<<endl<<endl;
	cin>>Filename;
	cout<<"CREATING OUTPUT FILE..............."<<endl;
	Outfile.open(Filename,ios::out);
	cout<<"BEGINING WRITE PLEASE WAIT..............."<<endl;
	Outfile<<"********************************************************************************************"<<endl;
	Outfile<<"	"<<"NAME"<<"	"<<"TEST GRADES"<<"	"<<"ASSIGNMENT GRADE"<<"	"<<"EXAM GRADE"<<endl;
	Outfile<<"********************************************************************************************"<<endl<<endl;

	for(int I=0; I<N; I++)
	{
		Name_t fname,lname;
		Grade_t t1,t2,t3,t4,ag,eg;
		CSCI208Class[I].get_fname(fname);
		CSCI208Class[I].get_lname(lname);
		CSCI208Class[I].get_t1(t1);
		CSCI208Class[I].get_t2(t2);
		CSCI208Class[I].get_t3(t3);
		CSCI208Class[I].get_t4(t4);
		CSCI208Class[I].get_ag(ag);
		CSCI208Class[I].get_eg(eg);
		Outfile<<"   "<<fname<<" "<<lname<<"   "<<t1<<" "<<t2<<" "<<t3<<" "<<t4<<"   "<<ag<<"   "<<eg<<endl;
		Outfile<<"---------------------------------------------------------------------------------------"<<endl;
	};//end for loop
	Outfile<<"********************************"<<N<<"students in this file***********************************"<<endl;
	Outfile<<"********************************END-OF-REPORT**************************************************"<<endl;
	cout<<"DATA SUCESSFULLY WRITTEN TO FILE!"<<endl;
	cout<<"NOW SAVING AND CLOSING OUTPUT FILE PLEASE WAIT..............."<<endl<<endl;
	Outfile.close();
};//end of print

void Display(StudentArray CSCI208Class, int N)
{
	char choice[5];
	cout<<"Would you like to preview the student records output file? (Yes/No)"<<endl;
	cin>>choice;

	if(choice=="No"||"NO"||"no")
	{ cout<<"TERMINATING PROGRAM.................GOODBYE"<<endl;}
	else
	if(choice=="Yes"||"YES"||"yes")
	{ 
		cout<<"********************************************************************************************"<<endl;
		cout<<"	"<<"NAME"<<"	"<<"TEST GRADES"<<"	"<<"ASSIGNMENT GRADE"<<"	"<<"EXAM GRADE"<<endl;
		cout<<"********************************************************************************************"<<endl<<endl;

		for(int I=0; I<N; I++)
		{
			Name_t fname,lname;
			Grade_t t1,t2,t3,t4,ag,eg;
			CSCI208Class[I].get_fname(fname);
			CSCI208Class[I].get_lname(lname);
			CSCI208Class[I].get_t1(t1);
			CSCI208Class[I].get_t2(t2);
			CSCI208Class[I].get_t3(t3);
			CSCI208Class[I].get_t4(t4);
			CSCI208Class[I].get_ag(ag);
			CSCI208Class[I].get_eg(eg);
			cout<<"   "<<fname<<" "<<lname<<"   "<<t1<<" "<<t2<<" "<<t3<<" "<<t4<<"   "<<ag<<"   "<<eg<<endl;
			cout<<"----------------------------------------------------------------------------------"<<endl;
		};//end for loop
		cout<<"***"<<N<<" students in this file***"<<endl;
		cout<<"*****************END-OF-REPORT*******************"<<endl;
	}
	else
	{ cout<<"PLEASE ENTER EITHER YES or NO......................."<<endl;}
}//end display

anyone have any ideas? whats got the linker huffing and puffing?

For next time, don't necessarily start up a new thread when people might still be working on that exact same issue in your old one, it gets too confusing.

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.