I have a assignment which requires the use of multiple files.
I don't believe I am linking them together correctly. I'm using visual basic 2008 at the moment.
Ofter I get the program working I'll create a make file and test that.
I'm also not too familiar with the string.h library, so hopefully i am using that correctly.
If someone could tell me what I'm doing wrong I would greatly appreciate it.
I have a few experimental things I'm trying that I'm not sure about, Mainly using logic operators instead of if then statements for ensuring I'm indexing an array correctly, but due to the linking problems I haven't been able to test them.
Hopefully its something simple.
Thanks in advance.

Here is a copy of the assignment

Overview

Build a normalized student record system. Create a class to represent student data. You will also create classes to handle other specific types of data including dates and addresses. Your system will include all the necessary header files, cpp files, and a main program to incorporate the larger system.
Details

Imagine a university wants to keep track of the following data about each student:

* First name
* Last name
* address line 1
* address line 2
* city
* state
* zip code
* date of birth month
* date of birth day
* date of birth year
* anticipated completion month
* anticipated completion day
* anticipated completion year
* gpa
* credit hours completed

It is obvious that we will need a student class to contain all this data. However, the principles of data design indicate that the address should be its own class, as should the date. Your program should then have at least three classes: address, date, and student. Student will have two instances of date and one of address among its data members.
Process

Build all the classes you will need for this project. Each class should have a separate header file. This file contains only the class definition. Ensure your headers use the #ifndef structure described in lecture, and include whatever other headers they need.

Build a cpp file for each class which contains the code implementation of the class. This code file will include the class header file and any other headers and libraries needed.

Build a main program that imports all the needed classes and tests them. You'll then modify this program.

Create a makefile to control the compilation process. The instructor will test the program by running the make utility, so be sure your makefile works. If you use a visual editor like code::blocks, you'll still need to create and test a makefile for your project.
The complete project

When the classes are done, create a main program which does the following:

* Load up student data from a text file. All the needed information for the students should be in a text file, with each student's information on one line. You should have 50 students worth of data. NOTE: Please do not use real data. It might be helpful to write a program to generate fake data, or use the one at http://www.fakenamegenerator.com/gen-random-us-us.php
* Store student data on the heap Student data will be a large array, so it should be stored on the heap. Ensure you've also removed heap data when necessary.
* List all data for all students in a report format Create a method of the Student class to print a report about every student.
* Create a simpler list that prints only the last and first name of each student.
* Output a list of student names in alphabetical order Print the list in alphabetical order
* Build a simple sort utility. We'll talk more about sorting later, but the simplest type of sort to implement may involve creating a new blank array on the heap, finding the earliest name left in the primary array, and repeating until the temporary array is full.

Turning it in

This project will consist of a number of smaller files. You'll have a .cpp and a .h file for each class, a main.cpp file, a data file, and a makefile. Please turn in all files. Be sure all your files are properly documented.


HeaderFiles:
Address Class:

#ifndef string
#define string
	#include <string>
#endif

class Address {
	private:
		string Line1;
		string Line2;
		string City;
		string State;
		int Zip;
	public:
		//Get/Accessor functions
		  string GetLine1();
		  string GetLine2();
		  string GetCity();
		  string GetState();
		  int GetZip();
		//Set/Mutator functions
		 void SetLine1( string );
		 void SetLine2( string );
		 void SetCity( string );
		 void SetState( string );
		 void SetZip( int );
		 void SetAddress(string,string,string,string, int);
		//constructors
		 Address();
	};

Date Class:

class Date {
	private:
		int Year;
		int Month;
		int Day;
	public:
		//Get/Accessor functions
		  int GetYear();
		  int GetMonth();
		  int GetDay();
		//Set/Mutator functions
		 void SetYear( int );
		 void SetMonth(int );
		 void SetDay(int );
		 void SetDate(int,int,int);
		//constructors
		 Date();
};

Name Class:

#ifndef string
#define string
	#include <string>
#endif

class Name {
	private:
		string FirstName;
		string LastName;
	public:
		//Get/Accessor functions
		  string GetFirstName();
		  string GetLastName();
		//Set/Mutator functions
		 void SetFirstName( string );
		 void SetLastName( string );
		 void SetFullName(string,string);
		//constructors
		 Name();
};

Performance Class:

class Performance {
	private:
		float GPA;
		int Credits;
	public:
		//Get/Accessor functions
		  float GetGPA();
		  int GetCredits();
		//Set/Mutator functions
		 void SetGPA( float );
		 void SetCredits( int );
		 void SetPerformance(float,int);
		//constructors
		 Performance();
};

Student Class:

#ifndef string
#define string
	#include <string>
#endif

#ifndef Address
#define Address
	#include "Address.h"
#endif
#ifndef Date
#define Date
	#include "Date.h"
#endif
#ifndef Name
#define Name
	#include "Name.h"
#endif
#ifndef Performance
#define Performance
	#include "Performance.h"
#endif


class Student {
	private:
		Name SName;
		Address SAddress;
		Date SBirthDate;
		Date SGradDate;
		Performance SPerformance;
	public:
		//Get/Accessor functions.
		  Name GetSName();
		  Address GetSAddress();
		  Date GetSBirthDate();
		  Date GetSGradDate();
		  Performance GetSPerformance();
		  void Report();
		  void SimpleReport();
		//Set/Mutator Functions
		 //none, just use sub-class's setfunctions.
		//constructors
		 Student();
};

aux cpp files:
Address Class's functions:

#ifndef Address
#define Address
	#include "Address.h"
#endif

#ifndef string
#define string
	#include <String.h>
#endif
//Get/Accessor functions
string Address :: GetLine1( ){ return Line1;}
string Address :: GetLine2(){return Line2;}
string Address :: GetCity(){return City;}
string Address :: GetState(){return State;}
int Address :: GetZip(){return Zip;}
//Set/Mutator functions
void Address :: SetLine1( string NewLine1 ){Line1 = NewLine1;}
void Address :: SetLine2( string NewLine2 ){Line2 = NewLine2;}
void Address :: SetCity( string NewCity ){City = NewCity;}
void Address :: SetState( string NewState ){State = NewState;}
void Address :: SetZip(int NewZip ){Zip=NewZip;}
void Address :: SetAddress(string NewLine1,string NewLine2,string NewCity,string NewState, int NewZip){SetLine1(NewLine1);SetLine2(NewLine2);SetCity(NewCity);SetState(NewState);SetZip(NewZip);}
//constructors
Address :: Address(){}

Date Class's functions:

#ifndef Date
#define Date
	#include "Date.h"
#endif
//Get/Accessor functions
int Date :: GetYear(){return Year;}
int Date :: GetMonth(){return Month;}
int Date :: GetDay(){return Day;}
//Set/Mutator functions
void Date :: SetYear( int NewYear){Year = NewYear;}
void Date :: SetMonth(int NewMonth){Month = NewMonth;}
void Date :: SetDay(int NewDay){Day = NewDay;}
void Date :: SetDate(int NewDay,int NewMonth,int NewYear){SetDay(NewDay);SetMonth(NewMonth);SetYear(NewYear);}
//constructors
Date :: Date(){}

Name Class's functions:

#ifndef Name
#define Name
	#include "Name.h"
#endif

#ifndef string
#define string
	#include <String.h>
#endif

//Get/Accessor functions
string Name :: GetFirstName( return FirstName;){}
string Name :: GetLastName(){return LastName;}
//Set/Mutator functions
void Name :: SetFirstName( string NewFirstName ){FirstName = NewFirstName;}
void Name :: SetLastName( string NewLastName){LastName = NewLastName;}
void Name :: SetFullName(string NewFirstname,string NewLastName){SetFirstName(NewFirstName);SetLastName(NewLastName);}
//constructors
Name :: Name(){}

Performance Class's functions:

#ifndef Performance
#define Performance
	#include "Performance.h"
#endif
//Get/Accessor functions
float Performance :: GetGPA(){return GPA;}
int Performance :: GetCredits(){return Credits;}
//Set/Mutator functions
void Performance :: SetGPA( float NewGPA ){GPA=NewGPA;}
void Performance :: SetCredits( int NewCredits){Credits=NewCredits;}
void Performance :: SetPerformance(float NewGPA,int NewCredits){SetGPA(NewGPA);SetCredits(NewCredits);}
//constructors
Performance :: Performance(){}

Student Class's functions:

#ifndef Student
#define Student
	#include "Student.h"
#endif

#ifndef iostream
#define iostream
	#include <iostream.h>
#endif

//Get/Accessor functions.
Name Student :: GetSName(){return SName;}
Address Student :: GetSAddress(){return SAddress;}
Date Student :: GetSBirthDate(){return SBirthDate;}
Date Student :: GetSGradDate(){return SGradDate;}
Performance GetSPerformance(){return SPerformance;}
//Utility Functions{}
void Student :: Report(){
cout <<"|--------------------------- \n";
cout <<"Student's Name: \n";
cout <<"	First Name: "<<this.GetSName.GetFirstName()<<" \n";
cout <<"	Last  Name: "<<this.GetSName.GetLastName()<<" /n";
cout <<"Student's Address: \n";
cout <<"	First  Line: "<<this.GetSAddress.GetFirstLine() <<" \n";
cout <<"	Second Line: "<<this.GetSAddress.GetSecondLine()<<" \n";
cout <<"	City	   : "<<this.GetSAddress.GetCity()		<<" \n";
cout <<"	State	   : "<<this.GetSAddress.GetState()	    <<" \n";
cout <<"	Zip		   : "<<this.GetSAddress.GetZip()		<<" \n";
cout <<"Student's BirthDate: \n";
cout <<"	Day  : "<<this.GetSBirthDate.GetDay()  <<" \n";
cout <<"	Month: "<<this.GetSBirthDate.GetMonth()<<" \n";
cout <<"	Year : "<<this.GetSBirthDate.GetYear() <<" \n";
cout <<"Student's GradDate: \n";
cout <<"	Day  : "<<this.GetSGradDate.GetDay()  <<" \n";
cout <<"	Month: "<<this.GetSGradDate.GetMonth()<<" \n";
cout <<"	Year : "<<this.GetSGradDate.GetYear() <<" \n";
cout <<"Student's Performance: \n"
cout <<"	GPA	   : "<<this.GetSPerformance().GetGPA()<<" \n";
cout <<"	Credits: "<<this.GetSPerformance().GetCredits()<<" \n";
cout <<"|--------------------------- \n";
}
void Student :: SimpleReport(){
cout <<"|--------------------------- \n";
cout <<"Student's Name: \n";
cout <<"	First Name: "<<this.GetSName.GetFirstName()<<" \n";
cout <<"	Last  Name: "<<this.GetSName.GetLastName()<<" /n";
cout <<"|--------------------------- \n";
}
//Set/Mutator Functions
	//none, just use sub-class's setfunctions.
//constructors
Student :: Student(){}

Main cpp file:

#include <iostream.h>
#include <fstream>
#include <stdio.h>

#ifndef iostream
#define iostream
	#include <iostream.h>
#endif
#ifndef string
#define string
	#include <string.h>
#endif

#define STUDENTNUMBER 50 // Don't change with out also changing numerous things in TextGenerate Function.

#include "AddressFunctions.cpp"
#include "DateFunctions.cpp"
#include "NameFunctions.cpp"
#include "PerformanceFunctions.cpp"
#include "StudentFunctions.cpp"



//Function Declarations
void Print(*Student,int);
void SimplePrint(*Student,int);
void Alphabetize(*Student);
int TextGeneration();
//Function Definitions
void Print(*Student SArrayP,int Alphabetize){
	if(Alphabetize != 1){
		Alphabetize(SArrayP);
	}
	int i;
	for(i=0; i<STUDENTNUMBER;i++){
		SArrayP->Print();
		SArray+=1;
	}
}
void SimplePrint(*Student SArrayP,int Alphabetize){
	if(Alphabetize != 0){
		Alphabetize(SArrayP);
	}
	int i;
	for(i=0; i<STUDENTNUMBER;i++){
		SArrayP->SimplePrint();
		SArray+=1;
	}
}
void Alphabetize(*Student SArrayP){ // basic bubble sort, http://www.daniweb.com/software-development/cpp/code/216454 Helped alot. not 100% sure it'll work.
	int i;//counter
	int j;//counter
	for(i=0;i<STUDENTNUMBER-1;i++){
		for(j=0;j<STUDENTNUMBER-1-i;j++){
			//combine first and last names into full names, and compare, swap if first is greater then second
			if(strcmp((SArrayP->GetSName().GetFirstName())+=" " +=(SArrayP->GetSName().GetLastName()),((SArrayP+1)->GetSName().GetFirstName())+=" "+=((SArrayP+1)->GetSName().GetLastName()))>0){
				swap(SArrayP[j],SArrayP[j+1])
			}
		}
	}		
}


int TextGeneration () {
  srand(STUDENTNUMBER); // NOTE TO self: Make based on time when done debugging
  ofstream Data;
  Data.open ("Data.txt");
  if(Data.is_open()){
	 int i; // counter
	 int j; // counter
	//Name info
	 string new FirstName[STUDENTNUMBER];
	 string new LastName[STUDENTNUMBER];
	//Address info
	 string new Line1[STUDENTNUMBER];
	 string new Line2[STUDENTNUMBER];
	
	//variables to generate Unique full names
	 string new FirstNames1[5] = {"Allen","Bob","Charles","Dan","Edward"};
	 string new FirstNames2[5] = {"Adriene","Betty","Charlie","Danny","Edna"};
	 string new LastNames1[5] = {"Fnord","Gary","Howard","eyes","Joshua"};
	 string new LastNames2[5] = {"Fockers","Great","Henry","Its","Jones"};
	 string new FirstNames[2] = {FirstNames1,FirstNames2};
	 string new LastNames[2] = {LastNames1,LastNames2}; 
	 
	 // Variables to generate random unique addresses
	 string new Lines1[5] = {"159 faternity st.","399 Dorm Blvd.","222 faternity st.", "777 Dorm Blvd", "82 Canal street");
	 string new Lines2[10] = {"Apartment A", "Apartment B", "Apartment C", "Apartment D", "Apartment E","Apartment F", "Apartment G", "Apartment H", "Apartment I"};
//Note to Self, Works?
	 for(i=0;i<STUDENTNUMBER;i++){
		 for(j=0; j<5; j++){
			strCopy(FirstName[i],FirstNames[i>25][j]);//not 100% sure if this will work.
			strCopy(LastName[i],LastNames[i>25][j + floor(i/5)-(i>25)*(floor(i/5)-6)- 4*((j+i/5)>5)]);
			//^^Not 100% sure if this will work, changes to correct variables based on the value of other variables^^
		 }
	 }


  
// The above and below works?
 
	for(i=0;i<STUDENTNUMBER;i++){
		 for(j=0; j<10; j++){
			strCopy(Line1[i],Lines1[j]);// Not 100% sure if this will work
			strCopy(Line2[i],Lines2[j + floor(i/10)-(i>25)*(floor(i/10)-11)- 4*((j+i/10)>10)]);
			//^^This works2?, changes to correct variables based on the value of other variables
		 }
	 }
//The above works?

	//deallocate unneeded variables
	delete [] FirstNames1;
	delete [] FirstNames2;
	delete [] LastNames1;
	delete [] LastNames2;
	delete [] FirstNames;
	delete [] LastNames;

	 for(i=0; i<STUDENTNUMBER;i++){
			// name info
			Data << FirstName[i] << "\n"; // first name
			Data << LastName[i] << "\n"; // last name
			// address info
			Data << Line1[i] <" \n"; // line 1
			Data << Line2[i] " \n"; // line 2
			Data << "Indianapolis  \n"; // city
			Data << "IN  \n"; // state
			Data << "46168 \n"; // zip
			// birthdate info
			Data << rand()%28 + 1  << " \n"; //day
			// ^^ No one is born between the 29th though 31st of any month, easier coding. ^^
			Data << rand()%12 + 1 << " \n";//month
			Data << 2011 -(rand()%49 + 12)<< "\n";//year
			//graddate info
			Data << rand()%28 + 1 << " \n";//day
			// ^^ No one Graduates between the 29th though 31st of any month, easier coding. ^^
			Data << rand()%12 + 1 << " \n"; // month
			Data << 2011 + (rand()%6+2)<< " \n; // year
			//performance info
		    Data << (rand()%16)/(float rand()%4)<<" \n"; //gpa
			Data << (rand()%300)<< " \n"; //credits
			// ^^ no one has 300 or more credits. ^^
	 }
	
	 //Deallocate rest of memory
		delete [] FirstName;
		delete [] LastName;
		delete [] Line1;
		delete [] line2;
		

	 Data.close();
	 } else {
		cout << "Data File failed to open. \n";
	 }
  return 0;
}


int main(){
		ifstream Data;
		Data.open("Data.txt",ios::in);
		Student new Students[STUDENTNUMBER];
		string StudentInfo;
		char Request;
		int i = 0; // counter
		int Alphabetize=0;

		if(!Data.is_open()){ // create file if it is not already created.
			Date.close("Data.txt");
			TextGeneration();
			Data.open("Data.txt");
		}
		if(Data.is_open()){
			while ( Data.good() || i<STUDENTNUMBER){
				
				
				//AssignNames
				getline(Data,StudentInfo);
				Students[i].GetSName().SetFirstName(StudentInfo);
				getline(Data,StudentInfo);
				Students[i].GetSName().SetLastName(StudentInfo);
				//AssignAddress
				getline(Data,StudentInfo);
				Students[i].GetSAddress().SetLine1();
				getline(Data,StudentInfo);
				Students[i].GetSAddress().SetLine2(StudentInfo);
				getline(Data,StudentInfo);
				Students[i].GetSAddress().SetCity(StudentInfo);
				getline(Data,StudentInfo);
				Students[i].GetSAddress().SetState(StudentInfo);
				getline(Data,StudentInfo);
				Students[i].GetSAddress().SetLineZip(int(StudentInfo)); // not sure if type casting is neccassry or not, or if it returns the right value.
				//AssignBirthDate
				getline(Data,StudentInfo);
				Students[i].GetSBirthDate().SetDay(int(StudentInfo));
				getline(Data,StudentInfo);
				Students[i].GetSBirthDate().SetMonth(int(StudentInfo));
				getline(Data,StudentInfo);
				Students[i].GetSBirthDate().SetYear(int(StudentInfo));
				//AssignGradDate
				getline(Data,StudentInfo);
				Students[i].GetSGradDate().SetDay(int(StudentInfo));
				getline(Data,StudentInfo);
				Students[i].GetSGradDate().SetMonth(int(StudentInfo));
				getline(Data,StudentInfo);
				Students[i].GetSGradDate().SetYear(int(StudentInfo));
				//AssignPerformance
				getline(Data,StudentInfo);
				Students[i].GetSPerformance().SetGPA(float(StudentInfo));
				getline(Data,StudentInfo);
				Students[i].GetSPerformance().SetCredits(int(StudentInfo));
				i++
				
			}

			cout << "Would you like to print a list? Enter Y for yes, N for no please. \n";
			cin >> Request;
			if(Request == 'Y' || request =='y'){
				cout << " Would you like the list to be alphabatized? Enter Y for yes, N for no please. \n"
				cin >> Request;
				if(Request == 'Y' || request =='y'){
					Alphabetize = 1;
				}
				cout << " Would you like the list Simple? Enter Y for yes, N for no please. \n"
				cin >> Request;
				if(Request == 'Y' || request =='y'){
					SimplePrint(*Students,Alphabetize);
				} else {
					Print(*Students,Alphabetize);
				}
			}
			cout << "Thank you and have a nice day. \n";
		} else {
			cout << "File Could not Open.";
		}
		Data.close("Data.txt");
		//deallocate memory
		delete [] Students;
	return 0;
}

Actually you're pretty far from linking trouble. You have major compilation issues.
Few things you need to fix and remember:
1. DO NOT USE things like "Student", "iostream", "Name", "Date" as include guards. Make YOUR include guards unique. Qualify these names with your street address if needed. E.g. #ifndef student_Casper3912_myCountry_myCity_myStreet.
==> Better use #pragma once
2. Include guards are placed in .h file NOT in .cpp files (those days are gone!)
3. Be careful in what you include, following 3 are not the same:

#include <string>
#include <string.h>
#include <String.h>

4. Never #include .cpp files (main.cpp)
5. Don't use this. unless you know what you're doing.
6. A function call must have () at the end. :) E.g. From Student.cpp

this.GetSName.GetFirstName()
// should be:
GetSName().GetFirstName()

7. You need to add using std::cout, std::string etc wherever required.


I've fixed all errors in Student class and attached. See that example and fix other places.

Attachments..

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.