5 Replies - 330 Views - Last Post: 28 April 2012 - 12:53 PM Rate Topic: -----

#1 lace11681  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-April 12

Error unresolved external symbol in grader program

Posted 28 April 2012 - 11:23 AM

I keep getting an error LNK2019: unresolved external symbol "public: void __thiscall Report::print_heading(void)" (?print_heading@Report@@QAEXXZ) referenced in function _main
and everything i have tried as yet to work.

//header section
#include <iostream>
#include <fstream>
#include <iomanip>
#include<cmath>
#include <cstdlib>
#include <iostream>
#include <conio.h>		// for _getch() function


using namespace std;


class Report
{
private:
	char id [12];
	char name [20];
	double midterm, h1, s1, s2, s3,cp;
	ifstream in_file;

public:
	Report ();
	~Report ();

	void print_heading();
	void read_input();
	int calc_grade();
	char convert_grade(int);
	void display_result(char, int);
	ifstream & get();

};

Report::Report()
{
	in_file.open ("C://prg5data.txt");

		if (!in_file)
	{
		cerr<<"Error:File could not be opened"<<endl;
		cerr<<"Program terminating"<<endl;
		exit(1);
	}
}

void Report::read_input()
{ 
	in_file.getline(id, 12);
	in_file.getline(name, 20);
	in_file>>midterm>>h1>>s1>>s2>>cp;
	in_file.get();
}

int Report::calc_grade()
{
	int course_grade;

	course_grade = (int)((midterm*0.25)+(h1*0.25)+(s1*0.20)+(s2*0.20)+(cp*0.10));

	return course_grade;
}

char Report::convert_grade(int grade)
{
	if (grade>=90&&grade<=100)
		return 'A';
	else if (grade>=80&&grade<90)
		return 'B';
	else if (grade>=70&&grade<80)
		return 'C';
	else if (grade>=60&&grade<70)
		return 'D';
	else if (grade>=50&&grade<60)
		return 'E';
	else if (grade>=40&&grade<=50)
		return 'F';
}

void Report::display_result (char letter, int grade)
{
	cout << setw(5)<< "Student#" << setw(15) << "Student Name" << setw(5)
		<< "MT" << setw(5) << "FL"
		<< setw(5) << "s1" << setw(5) << "s2" << setw(5) 
	<< "CP" << setw(5)<< "CGN" << setw (5)<< "CGL"<<endl;
		cout<<"-----------------------------------------------------------------------------------------";

	//cout<< setw(12)<<id<<setw(20)<<name<<setw(3)<<midterm<<setw(3)<<h1<<setw(3)<<s1<<setw(3)<<s2<<
	//setw(3)<<letter<<setw(3)<<grade<<endl;
}

ifstream &Report::get()
{
	return in_file;
}

Report::~Report()
{
	in_file.close();
}

int main()
{
	int grade;
	char letter;
	
	Report s1;
	s1.print_heading();
	ifstream &read_file=s1.get();
	s1.read_input();
	
	while (!read_file.eof())
	{
		grade=s1.calc_grade();
		letter=s1.convert_grade(grade);
		s1.display_result (letter, grade);
		s1.read_input();

		cout<<setw(3)<<letter<<setw(3)<<grade<<endl;
	}


	_getch();
	return 0;


}


This post has been edited by sarmanu: 28 April 2012 - 11:29 AM
Reason for edit:: Fix code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Error unresolved external symbol in grader program

#2 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 965
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: Error unresolved external symbol in grader program

Posted 28 April 2012 - 11:30 AM

Umm you didn't implement Report::print_heading() anywhere ... it's only defined.
Was This Post Helpful? 0
  • +
  • -

#3 lace11681  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-April 12

Re: Error unresolved external symbol in grader program

Posted 28 April 2012 - 11:35 AM

Can you give me a hint on how to do that?
Was This Post Helpful? 0
  • +
  • -

#4 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1578
  • View blog
  • Posts: 3,004
  • Joined: 30-May 10

Re: Error unresolved external symbol in grader program

Posted 28 April 2012 - 11:38 AM

It's the same way you got from
void display_result(char, int);

to
void Report::display_result (char letter, int grade) {
  // do some actual stuff
}


Was This Post Helpful? 0
  • +
  • -

#5 lace11681  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-April 12

Re: Error unresolved external symbol in grader program

Posted 28 April 2012 - 12:44 PM

OK i think i'm on the right track now

I am not getting any out put now


//header section
#include <iostream>
#include <fstream>
#include <iomanip>
#include<cmath>
#include <cstdlib>
#include <iostream>
#include <conio.h>		// for _getch() function


using namespace std;


class Report
{
private:
	char id [12];
	char name [20];
	double midterm, f1, p1, p2, p3,cp;
	ifstream in_file;

public:
	Report ();
	~Report ();

	void print_heading(char, int);
	void read_input();
	int calc_grade();
	char convert_grade(int);
	void display_result(char, int);
	ifstream & get();
	

};
int studentType;
int getInput ( const int );	// send over array of 30 students to get input
									// return how many students are read
									// open input file should be done here

void process ( const int );	// send over number of students really stored in 
										// array to calculate grade for each student

void display ( const int );	// send over number of students really 
											// stored in array to display
											// open output file should be done here


Report::Report()
{
	in_file.open ("prg5data.txt");

		if (!in_file)
	{
		cerr<<"Error:File could not be opened"<<endl;
		cerr<<"Program terminating"<<endl;
		system("pause");
		exit(1);
	}
}
void Report::print_heading (char letter, int grade)
{	cout<<"STUDENT ID	HW AVE	TEST AVE	FINAL SCORE	GRADE\n123456789    89.8  	 82.8  	   85.6     B\n\n234567890   98.1  	 93.8  	 95.5     A\n\n345678901   92.5   80.0    85.0     B"<<endl;
		cout<<"---------------------------------------------------------------------------";


}
void Report::read_input()
{ 
	in_file.getline(id, 12);
	in_file.getline(name, 20);
	in_file>>midterm>>f1>>p1>>p2>>cp;
	in_file.get();
}

int Report::calc_grade()
{
	int course_grade;

	course_grade = (int)((midterm*0.25)+(f1*0.25)+(p1*0.20)+(p2*0.20)+(cp*0.10));

	return course_grade;
}

char Report::convert_grade(int grade)
{
	if (grade>=90&&grade<=100)
		return 'A';
	else if (grade>=80&&grade<89.9)
		return 'B';
	else if (grade>=70&&grade<79.9)
		return 'C';
	else if (grade>=60&&grade<69.9)
		return 'D';
	else if (grade<60)
		return 'E';

}

void Report::display_result (char letter, int grade)
{
	cout << "" <<endl;
		cout<<"---------------------------------------------------------";

	//cout<< setw(12)<<id<<setw(20)<<name<<setw(3)<<midterm<<setw(3)<<f1<<setw(3)<<p1<<setw(3)<<p2<<
	//setw(3)<<letter<<setw(3)<<grade<<endl;
}

ifstream &Report::get()
{
	return in_file;
}

Report::~Report()
{
	in_file.close();
}

int main()
{
	int grade;
	char letter;
	
	Report s1;
	s1.print_heading(grade, letter);
	ifstream &read_file=s1.get();
	s1.read_input();
	
	while (!read_file.eof())
	{
		grade=s1.calc_grade();
		letter=s1.convert_grade(grade);
		s1.display_result (letter, grade);
		s1.read_input();


		cout<<setw(3)<<letter<<setw(3)<<grade<<endl;
	


	_getch();
	return 0;


}




}




:code:

This post has been edited by jimblumberg: 28 April 2012 - 12:46 PM
Reason for edit:: Fixed Code Tags

Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg  Icon User is offline

  • member icon


Reputation: 3845
  • View blog
  • Posts: 11,753
  • Joined: 25-December 09

Re: Error unresolved external symbol in grader program

Posted 28 April 2012 - 12:53 PM

You may want to look at the placement of the return in main. Do you really want this return to be in the loop? If moving this return doesn't help post a small sample of your input file.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1