Error: unresolved external symbol

thanks for all help me

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 1567 Views - Last Post: 23 November 2008 - 12:27 PM Rate Topic: -----

#1 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Error: unresolved external symbol

Posted 21 November 2008 - 07:37 AM

:wub: welcom :wub:

i have error in my cod when i build program
the header
#ifndef STUDENT_H_
#define STUDENT_H_

#include <iostream>
using namespace std;

#include <string>
using namespace std;

class Student{
	private:
		static int serialId;
		const int id;
		string name;
		int currentCourses;
		bool canRegisterMore();
		
	public:
		Student(string studentName);
	
		bool registerCourse();
	
		void dropCourse();
	
		void printDetails();
	
};
#endif /*STUDENT_H_*/






the .cpp




#include"Student.h"


int Student::serialId=0;


Student::Student(string studentName):id(serialId)//intilizer member list
{
	name=studentName;
	currentCourses=0;
	serialId++;
}








bool Student::canRegisterMore()
{
	if(currentCourses<4)
		return true;

	else
		return false;
}

bool Student::registerCourse()
{
	if(canRegisterMore()==true)
	{
		return true;
		   cout<<"you can Register course";
			currentCourses++;
			else 
				return false;
			cout<<"Sory you cannot Register course !";
	}
}


	void Student::dropcourse()
	{
		if (currentCourses>0)
		{
			currentCourses--;
			else 
				cout<<"Error!"
		}

	}


	void Student::printDetails()
	{
		cout<<"The student name is:\n"<<studentName;
		cout<<"The student ID is:\n"<<id;
		cout<<"The currentCourses is:\n"<<currentCourses<<endl;
		cout<<"The student abilety for registr corse is:\n"<<registerCourse();
	}






the main

#include"Student.h"

int main()
{
		

Student StudentObj("Ameerah");
StudentObj.printDetails();
return 0;
}

		




the error mesge is:

--------------------Configuration: main - Win32 Debug--------------------
Linking...
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Student::printDetails(void)" (?printDetails@Student@@QAEXXZ)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall Student::Student(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Student@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@
D@2@@std@@@Z)
Debug/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

main.exe - 3 error(s), 0 warning(s)



pleas help me because i must give the tetcher on sturday :(

Is This A Good Question/Topic? 0
  • +

Replies To: Error: unresolved external symbol

#2 jderecho  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 26
  • Joined: 23-July 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 08:34 AM

You have quite a few problems to address before you get to the link errors.

In the code for there is a "else" that does not match any "if", for example in the function "canRegisterMore()" and "dropCourse()" to name a couple. In that area also there are return statements followed by code that will never be executed.

You need to correct the syntax errors before looking at any linking errors.
Was This Post Helpful? 0
  • +
  • -

#3 manzoor  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 13
  • View blog
  • Posts: 468
  • Joined: 07-August 07

Re: Error: unresolved external symbol

Posted 21 November 2008 - 09:07 AM

There were few errors I have corrected them

Here's your Student.cpp file
#include "Student.h"

int Student::serialId = 0;


Student::Student(string studentName) : id(serialId)		//intilizer member list
{
    name = studentName;
    currentCourses = 0;
    serialId++;
}

bool Student::canRegisterMore()
{
    if(currentCourses < 4)
        return true;
    else
        return false;
}

bool Student::registerCourse()
{

	if (canRegisterMore() == true)
    {
        // You should first print and increment currentCourses
		// because it'll return and not print and increment
		cout << "You can register course";
        currentCourses++;
		return true;
	}
	else
	{
		 cout << "Sory you cannot Register course !";
		 return false;
	}
}


    void Student::dropCourse() // its dropCourse not dropcourse
    {
        if (currentCourses > 0)
            currentCourses--;
        else
			cout<<"Error!"; // No semicolon here
    }


    void Student::printDetails()
    {
        cout<<"The student name is:\n"<<name; // you typed studentName
        cout<<"The student ID is:\n"<<id;
        cout<<"The currentCourses is:\n"<<currentCourses<<endl;
        cout<<"The student abilety for registr corse is:\n"<<registerCourse();
    }




I have corrected the code and commented the errors :).
You have errors in your if...else statements. You don't have an if statement for your else statement, it is there, but outside the braces which is not associated with the else inside it.

And, you are returning before printing or incrementing your variables, which is not correct, because the function would get back to the caller function without incrementing your variables and printing the message.

You have mistyped the dropCourse function name as dropcourse(), also an error.

And in the printDetails() function your are printing a studentName, but there is no studentName variable in this scope, I'm sure you may be referring to name here so it should print name data member instead.

I hope this helped ;)

This post has been edited by manzoor: 21 November 2008 - 09:16 AM

Was This Post Helpful? 0
  • +
  • -

#4 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 09:11 AM

pleas write corect of my error

i dont standread english wll, pleas write error and how to correct

pleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeas^___^

pleas write corect of my error

i dont standread english wll, pleas write error and how to correct

pleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeas^___^
Was This Post Helpful? 0
  • +
  • -

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Error: unresolved external symbol

Posted 21 November 2008 - 09:12 AM

Topic renamed.
Was This Post Helpful? 0
  • +
  • -

#6 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 09:14 AM

manzoor

thankkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkyou

tahanks alot
Was This Post Helpful? 0
  • +
  • -

#7 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 09:49 AM

manzoor pleas help me

the code include logic error

not print the name and id????




NOT print name and not print id :blink:
Was This Post Helpful? 0
  • +
  • -

#8 manzoor  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 13
  • View blog
  • Posts: 468
  • Joined: 07-August 07

Re: Error: unresolved external symbol

Posted 21 November 2008 - 10:06 AM

Can u be a little explicit and tell me what you mean?

Do you mean that it is not printing the ID and Name?
Was This Post Helpful? 0
  • +
  • -

#9 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 10:11 AM

iam sory

yes not print
Was This Post Helpful? 0
  • +
  • -

#10 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 11:25 AM

pleas manzoor pleas help me

or any another programmer

iam sad;
Was This Post Helpful? 0
  • +
  • -

#11 manzoor  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 13
  • View blog
  • Posts: 468
  • Joined: 07-August 07

Re: Error: unresolved external symbol

Posted 21 November 2008 - 11:30 AM

Well it's working fine for me


#ifndef STUDENT_H_
#define STUDENT_H_

#include <iostream>
using namespace std;

#include <string>
using namespace std;

class Student{
    private:
        static int serialId;
        const int id;
        string name;
        int currentCourses;
        bool canRegisterMore();
        
    public:
        Student(string studentName);
    
        bool registerCourse();
    
        void dropCourse();
    
        void printDetails();
    
};
#endif /*STUDENT_H_*/


#include "Student.h"

int Student::serialId = 0;


Student::Student(string studentName) : id(serialId)		//intilizer member list
{
    name = studentName;
    currentCourses = 0;
    serialId++;
}

bool Student::canRegisterMore()
{
    if(currentCourses < 4)
        return true;
    else
        return false;
}

bool Student::registerCourse()
{

	if (canRegisterMore() == true)
    {
        // You should first print and increment currentCourses
		// because it'll return and not print and increment
		cout << "You can register course ";
        currentCourses++;
		return true;
	}
	else
	{
		 cout << "Sory you cannot Register course !";
		 return false;
	}
}


    void Student::dropCourse() // its dropCourse not dropcourse
    {
        if (currentCourses > 0)
            currentCourses--;
        else
			cout<<"Error!"; // No semicolon here
    }


    void Student::printDetails()
    {
        cout<<"The student name is: "<<name << endl; // you typed studentName
        cout<<"The student ID is:"<<id << endl;
        cout<<"The currentCourses is:"<<currentCourses<<endl;
        cout<<"The student abilety for registr corse is:"<<registerCourse() << endl;
    }



EDIT: It is printing the name and ID but in the next line... I have edited that for you. Check now

This post has been edited by manzoor: 21 November 2008 - 11:31 AM

Was This Post Helpful? 0
  • +
  • -

#12 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 12:09 PM

manzoor

tanhks very very mutch

the program is run andgood out put^_^



manzoor i have anoter question


You are required to implement a student registration system. The system keeps information about the students including their id, which is an automatic number issued by the system, a name, and current number of courses. It is important to keep the count of courses a student is currently enrolled in since he is only allowed to register for 4 courses at any given point in time. The system should facilitate course registration and dropping through appropriate functions. The system should also keep record of the date in which the student enrolled.
Information about courses is also needed. For each course, the id and number of credits is stored. The id of the course is a single string composed of two parts: a two character code specifying the major (e.g. CS for Computer Science, MA for Mathematics, EC for economics.. etc) and a serial number, which, unlike the code, is generated by the system.


Task A
Create a header file for the class student which contains the following header, then write its implementation file.
(tese finish soulotion)



Task B
Write a course class which contains number of credits and a string id. In addition to the constructor, it should contain a print function.



idont know how to combin betwwen charcter and inreger in asingle string

{The id of the course is a single string composed of two parts: a two character code specifying the major (e.g. CS for Computer Science, MA for Mathematics, EC for economics.. etc) and a serial number, which, unlike the code, is generated by the system}

thise my code:

the header

#ifndef COURSE_H_
#define COURSE_H_

#include <iostream>
using namespace std;

#include<string>
using namespace std;
class Course

{
private:

string id[4];// idont know this right or wrong

int NumberOfCredits;

static string serialId;



public:


Course(string corsename)
{

}

void print()
{
	
}
};
#endif/*COURSE_H_*/



the .cpp



#include"Course.h"




 int serialId=001;

Course:Course(string corsename,int number of cridet)
{
	name=corsename;
	numberofcredits=1;
	id={strncpy(id,corsename,2),serialId};//my teatcher say this methoed wrong to combin between charcter and intger

	serialId++;

NumberOfCredits=number of cridet;
}

	   

	  
	   

void Course::print()
{
	cout<<"The name of course is:\n"<<corsename;
	cout<<"The Id of course is:\n"<<;
		cout<<"The number of cridet is:"<<numberofcredits<<endl;
}





the main


#include"Course.h"
int main()
{

Course CourseObj("Ma",4);//Ma is firste and seconed charecter of Math
CourseObj=print();
return 0;
}



:wub: :wub: :wub: thanks manzoon for help me :wub: :wub: :wub:
Was This Post Helpful? 0
  • +
  • -

#13 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 12:46 PM

manzoor

pleas answer me can you help me for another question

pleeeeeeeeeeas thise least question
Was This Post Helpful? 0
  • +
  • -

#14 Ameerah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 15-November 08

Re: Error: unresolved external symbol

Posted 21 November 2008 - 01:35 PM

any programer

can you helpe me in another code

pleas
pleas

i must give the teatcher on sturday

pleas
Was This Post Helpful? 0
  • +
  • -

#15 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,141
  • Joined: 14-September 07

Re: Error: unresolved external symbol

Posted 21 November 2008 - 08:31 PM

Just post the question and if someone is able they will usually help you.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2