Click here to Skip to main content
11,438,226 members (72,639 online)

C / C++ / MFC

 
AnswerRe: what is the purpose of & in constructors Pin
Erudite_Eric16-Dec-12 22:43
memberErudite_Eric16-Dec-12 22:43 
GeneralRe: what is the purpose of & in constructors Pin
alaaan7318-Dec-12 5:43
memberalaaan7318-Dec-12 5:43 
AnswerRe: what is the purpose of & in constructors Pin
CPallini16-Dec-12 23:42
mvpCPallini16-Dec-12 23:42 
GeneralRe: what is the purpose of & in constructors Pin
alaaan7318-Dec-12 5:42
memberalaaan7318-Dec-12 5:42 
AnswerRe: what is the purpose of & in constructors Pin
sajeesh.c17-Dec-12 5:33
membersajeesh.c17-Dec-12 5:33 
GeneralRe: what is the purpose of & in constructors Pin
alaaan7318-Dec-12 5:42
memberalaaan7318-Dec-12 5:42 
AnswerRe: what is the purpose of & in constructors [modified] Pin
April Fans22-Dec-12 21:32
memberApril Fans22-Dec-12 21:32 
Questionerror LNK2019: unresolved external symbol "public: SOLVED [modified] Pin
alaaan7314-Dec-12 1:24
memberalaaan7314-Dec-12 1:24 
i got this error message in my program :
1>Reservation.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Reservation::ID_sn(void)" (?ID_sn@Reservation@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Reservation::getReservationNumber(void)" (?getReservationNumber@Reservation@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

and this is the program it contain 2 header files and their cpp file plus the main file

Passenger . h
<pre>#ifndef PASSENGER_H //to avoid redefinition errors
#define PASSENGER_H
 
#include <iostream>
#include<string>
using namespace std;
 

class Passenger {  //passenger class definition

public:
	 Passenger(); //default constructor
	Passenger(string,string,long);//parameterized constructor  
	//set functions:
	void setPassengerName(string);
	void setPassportNumber(string);
	void setContactNumber(long);
	//get functions:
	string getPassengerName();
	string getPassportNumber();
	long getContactNumber();
 
	void printDetails();
	
private://data members :
	string passengerName;
	string passportNumber;
	long contactNumber;
}; //end class Passenger
#endif

Passenger . cpp
<pre>#include <iostream>
#include "Passenger.h"
using namespace std;
 
Passenger::Passenger(string a="",string b="",long c=0)//Constructor that initializes the data members to given parameters
{
	setPassengerName(a);
	setPassportNumber(b);
	setContactNumber(c);
} //end constuctor Passenger body

 
void Passenger::setPassengerName(string Pname)
{
	passengerName=Pname;
} //end function setPassengerName

void Passenger::setPassportNumber(string Pnum)
{
	passportNumber=Pnum;
} //end function setPassportNumber
void Passenger::setContactNumber(long Cnum)
{
	contactNumber=Cnum;
} //end function setContactNumber

string Passenger::getPassengerName()
{
	return passengerName;
} //end function getPassengerName
string Passenger::getPassportNumber()
{
	return passportNumber;
}//end function getPassportNumber
long Passenger::getContactNumber()
{
	return contactNumber;
} //end function getContactNumber

void Passenger::printDetails()
{
	cout<<"passenger name:            "<<getPassengerName()<<"\npassenger Passport Number: "<<getPassportNumber()<<
	"\npassenger contact number:  "<<getContactNumber()<<"\n\n";
} //end function printDetails

Reservation . h
<pre>#ifndef RESERVATION_H_  //to avoid redefinition errors
#define RESERVATION_H_
 
#include <iostream>
#include <string>
#include "Passenger.h"
 
using namespace std;
 

class Reservation{
 
private:
	static int sn;//serial number 
    const string ID; //first two letters of passanger name plus sn
	bool smokerSeat;
	Passenger passenger;
		
public:
	
 
	//Constructor taking the parameters of Passenger
	Reservation(string psngrName, long psngrPhone, string psngrPassport, bool 	smoke);
	
	//Constructor taking a Passenger object 
	Reservation(Passenger& psngr, bool smoke); 
	
	Passenger getPassenger();		
	bool isSmoker();// to check if the passenger is smoker or not  
	
	string getReservationNumber();	//getReservation number = getId 
	void printDetails(); // to print passenger details
	string ID_sn();
	
};
 

#endif /*RESERVATION_H_*/



main .cpp
<pre>#include <iostream>
#include "Passenger.h"
#include "reservation.h"

int main()
{
	Passenger passenger1("aar","k9",23596); //create an object for Passenger class with argument 
	Passenger *passengerPtr=&passenger1; //pointer that refrnce to the object 
	passengerPtr->printDetails();//calling 
	
	Reservation reservation("aarr",566,"t77",0);
	Reservation *reservationPtr=&reservation;
	reservationPtr->printDetails(); 
	
	system("PAUSE");
 
	
} //end main

Im a beginner in programming and that's problem make me really confused
** i think the problem in the Reservation.cpp
Because when i test the other file's it was working but after i added the implementation for the reservation header this problem was appeared

modified 14-Dec-12 7:41am.

AnswerRe: error LNK2019: unresolved external symbol "public: Pin
Jochen Arndt14-Dec-12 1:38
memberJochen Arndt14-Dec-12 1:38 
GeneralRe: error LNK2019: unresolved external symbol "public: Pin
alaaan7314-Dec-12 1:49
memberalaaan7314-Dec-12 1:49 
AnswerRe: error LNK2019: unresolved external symbol "public: Pin
Graham Breach14-Dec-12 1:40
memberGraham Breach14-Dec-12 1:40 
GeneralRe: error LNK2019: unresolved external symbol "public: Pin
alaaan7314-Dec-12 1:50
memberalaaan7314-Dec-12 1:50 
Questionhow to learn c++ according to my goal Pin
ziuss213-Dec-12 20:28
memberziuss213-Dec-12 20:28 
AnswerRe: how to learn c++ according to my goal Pin
Richard MacCutchan13-Dec-12 23:39
mvpRichard MacCutchan13-Dec-12 23:39 
GeneralRe: how to learn c++ according to my goal Pin
ziuss213-Dec-12 23:45
memberziuss213-Dec-12 23:45 
GeneralRe: how to learn c++ according to my goal Pin
Richard MacCutchan14-Dec-12 0:39
mvpRichard MacCutchan14-Dec-12 0:39 
AnswerRe: how to learn c++ according to my goal Pin
sajeesh.c14-Dec-12 0:24
membersajeesh.c14-Dec-12 0:24 
GeneralRe: how to learn c++ according to my goal Pin
ziuss214-Dec-12 1:02
memberziuss214-Dec-12 1:02 
GeneralRe: how to learn c++ according to my goal Pin
Richard MacCutchan14-Dec-12 3:16
mvpRichard MacCutchan14-Dec-12 3:16 
GeneralRe: how to learn c++ according to my goal Pin
ziuss214-Dec-12 4:23
memberziuss214-Dec-12 4:23 
GeneralRe: how to learn c++ according to my goal Pin
Richard MacCutchan14-Dec-12 4:33
mvpRichard MacCutchan14-Dec-12 4:33 
AnswerRe: how to learn c++ according to my goal Pin
Maximilien15-Dec-12 16:00
memberMaximilien15-Dec-12 16:00 
GeneralRe: how to learn c++ according to my goal Pin
ziuss215-Dec-12 21:10
memberziuss215-Dec-12 21:10 
GeneralRe: how to learn c++ according to my goal Pin
Maximilien16-Dec-12 2:55
memberMaximilien16-Dec-12 2:55 
GeneralRe: how to learn c++ according to my goal Pin
ziuss216-Dec-12 3:02
memberziuss216-Dec-12 3:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150506.1 | Last Updated 5 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid