Hello all I am trying to link a program using Vi for my class assignment and I am getting the following error in Vi when I try to link:

Assign4.o: In function `__static_initialization_and_destruction_0(int, int)':
Assign4.cpp:(.text+0x17b): undefined reference to `cCourselist::cCourselist()'
collect2: ld returned 1 exit status

Here is my source code:

//assignment number 4
#include<iomanip>
#include<iostream>
#include<fstream>
using namespace std;

const int NAMESIZE=11;
const int FILENAMESIZE=51;
const int ARRAYSIZE=20;
const int MAXCLASSSIZE=51;
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(){}
        void Display();
        cStudent(Name_t NewName, Grade_t NewGrade);
        cStudent &operator=(const cStudent student)
        {
            student.get_fname(fname);
            student.get_lname(lname);
            student.get_t1(t1);
            student.get_t2(t2);
            student.get_t3(t3);
            student.get_t4(t4);
            student.get_ag(ag);
            student.get_eg(eg);
        }//end cStudent &operator
        void Read(Infile_t &Infile);
        void Print(Outfile_t &Outfile);
        //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) const
        { strcpy(fname,this->fname);}
        void get_lname(Name_t &lname) const
        { strcpy(lname,this->lname);}
        int get_t1(Grade_t &t1) const
        { t1=this->t1; return t1;}
        int get_t2(Grade_t &t2) const
        { t2=this->t2; return t2;}
        int get_t3(Grade_t &t3) const
        { t3=this->t3; return t3;}
        int get_t4(Grade_t &t4) const
        { t4=this->t4; return t4;}
        int get_ag(Grade_t &ag) const
        { ag=this->ag; return ag;}
        int get_eg(Grade_t &eg) const
        { eg=this->eg; return eg;}
};



class cCourselist
{
    private:
        cStudent Student[MAXCLASSSIZE];
        int Numofstudent;
        void PrintHeader(Outfile_t &Outfile);
    public:
        cCourselist();
        void Load(Infile_t &Infile);
        void Print(Outfile_t &Outfile);
        void Display();
};//end of cCourselist

typedef cStudent StudentArray[30];
StudentArray Student;
cCourselist CSCI208;

void cStudent::Read(Infile_t &Infile)
{
    Infile<<fname<<lname<<t1<<t2<<t3<<t4<<ag<<eg;
};//end cStudent::Read

void cStudent::Print(Outfile_t &Outfile)
{
         Outfile<<setw(7)<<fname<<" "<<lname<<setw(6)<<t1<<" "<<t2<<" "<<t3<<" "<<t4<<"           "<<ag<<"              "<<eg<<endl;
        Outfile<<"******************************************************"<<endl;
};//end cStudent::Print

void cStudent::Display()
{
    cout<<setw(7)<<fname<<" "<<lname<<setw(6)<<t1<<" "<<t2<<" "<<t3<<" "<<t4<<"           "<<ag<<"              "<<eg<<endl;
        cout<<"******************************************************"<<endl;
};//end cStudent::Display
   

void cCourselist::Load(Infile_t &Infile)
{
    Filename_t Filename;
    cout<<"Enter the name of the datafile:"<<endl;
    cin>>Filename;
    Infile.open(Filename,ios::in);
    Student[Numofstudent].Read(Infile);
    while(!Infile.eof())
    {
        Numofstudent=Numofstudent+1;
        Student[Numofstudent].Read(Infile);
    }//end while
    Infile.close();
};//end of load

void cCourselist::Print(Outfile_t &Outfile)
{
    Filename_t Filename;
        cout<<"Please enter the name of the output file to be created:"<<endl;
        cin>>Filename;
        cout<<"Opening output file......."<<endl;
        Outfile.open(Filename,ios::out);

    Outfile<<setw(10)<<"Name"<<"    "<<"Test Grades"<<"    "<<"Assignment Grade"
        <<"    "<<"Exam Grade"<<endl;
    for(int I=0; I<Numofstudent; I++)
    {
        Student[I].Print(Outfile);
    }//end for
};//end print

void cCourselist::Display()
{
    cout<<"Name"<<"    "<<"Test Grades"<<"    "<<"Assignment Grade"
        <<"    "<<"Exam Grade"<<endl;
    for(int I=0; I<Numofstudent; I++)
    {
        Student[I].Display();
    }//end for
};//end display

int main()
{
    Infile_t Infile;
    Outfile_t Outfile;
    CSCI208.Load(Infile);
    CSCI208.Print(Outfile);
    CSCI208.Display();

    return 0;
}//end main

does anyone know whats happening?

thanks in advance

-atticusr5

Either define the cCourselist ctor or remove it's declaration from the class body so that the compiler is able to define one for the class

I thought VI was just a *nix text editor. Didn't know it was a compiler too.

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.