#ifndef AccountId
#define AccountId
#include <string>
#include <iostream>
using namespace std;
class Account
{
private:
string coursename;
int courselevel;
int coursecredit;
string coursecode;
Account *nextAccount;
Account *head;
public:
Account();//default Constructor
Account(string,string,int,int);//primary constructor
~Account();//destructor
Account * getNextAccount(); //gets the next account pointer
void setNextAccount(Account *); //sets the next account pointer
void Display();
void AddNode(string,string,int,int);
void DisplayList();
void DestroyList();
};
#endif
#include "Account.h"
#include <string>
#include <iostream>
using namespace std;
Account::Account(string an, string ab , int ac , int ax) //primary constructor
{
coursename = an;
coursecode = ab;
courselevel = ac;
coursecredit = ax;
nextAccount = NULL;
head = NULL;
}
void Account::DisplayList()
{
Account *temp = head;
while (temp != NULL)
{
temp->Display();
temp = temp->getNextAccount();
}
}
void Account::AddNode(string an, string ab , int ac , int ax)
{
//make the new node
Account *node = new Account(an,ab,ac,ax);
//if memory was sucessfully allocated
if (node != NULL)
{
//if this is the first node to be added
//or if list is empty
if (head == NULL)
{
head = node;//make the first element
}
else
{ ///if the list is not empty
Account *temp = head;
while(temp->getNextAccount() != NULL)
temp = temp->getNextAccount();//points temp to the next element
temp->setNextAccount(node);//the end is reached we insert the element
}
}
else
{
cout << "Error - out of memory while creating new node." << endl;
}
}
Account::~Account() //destructor
{
/*cout << "\nDestructor for node [" << getAccountNum() << "," <<
getAccountBal() << "]\n\n";*/
}
Account * Account::getNextAccount() //accessor for nextAccount pointer
{
return nextAccount;
}
void Account::setNextAccount(Account *na) //mutator for nextAccount pointer
{
nextAccount = na;
}
void Account::Display() //Display information in node
{
cout << coursename << " " << coursecode << " " << courselevel << " " << coursecredit;
cout << "\n";
}
void Account::DestroyList()
{
Account *temp;
while (head != NULL)
{
temp = head;
head = head->getNextAccount();
delete temp;
}
}
void main()
{
Account BankAccounts;
string coursename;
string coursecode;
int courselevel;
int coursecredit;
//Creates a file stream for the room text file and opens it for reading
fstream file;
file.open( "Courses.txt", ios::in);
if ( !file )
{
cout << "Error";
cout <<"\n\n";
}
else
{
//Read the contents of the file
while(file >> coursename >> coursecode >> courselevel >> coursecredit)
{
BankAccounts.AddNode(coursename,coursecode,courselevel,coursecredit);
}
}
BankAccounts.DisplayList();
BankAccounts.DestroyList();
cin.get();
}
I am getting an error
Error 1 error LNK2019: unresolved external symbol "public: __thiscall Account::Account(void)" (??0Account@@QAE@XZ) referenced in function _main C:\Users\Donellie Whyte\Desktop\test\test\Driver.obj
Error 2 error LNK1120: 1 unresolved externals C:\Users\Donellie Whyte\Desktop\test\Debug\test.exe
Edited by hbk, 05 March 2011 - 10:16 AM.


Sign In
Create Account


Back to top










