Click here to Skip to main content
11,647,748 members (70,295 online)

C / C++ / MFC

 
QuestionGraphics Interface (game) Pin
April Fans13-Dec-12 18:37
memberApril Fans13-Dec-12 18:37 
AnswerRe: Graphics Interface (game) Pin
Richard MacCutchan13-Dec-12 22:40
mvpRichard MacCutchan13-Dec-12 22:40 
GeneralRe: Graphics Interface (game) Pin
April Fans20-Dec-12 19:13
memberApril Fans20-Dec-12 19:13 
QuestionCompilation Problem Pin
BobInNJ13-Dec-12 14:15
memberBobInNJ13-Dec-12 14:15 
AnswerRe: Compilation Problem Pin
Graham Breach13-Dec-12 21:58
memberGraham Breach13-Dec-12 21:58 
GeneralRe: Compilation Problem Pin
BobInNJ14-Dec-12 11:16
memberBobInNJ14-Dec-12 11:16 
GeneralRe: Compilation Problem Pin
Graham Breach14-Dec-12 23:31
memberGraham Breach14-Dec-12 23:31 
Questionerror C2678: binary '=' Pin
alaaan7313-Dec-12 6:41
memberalaaan7313-Dec-12 6:41 
error message .cpp(44): error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const std::string' (or there is no acceptable conversion)
Header File :
#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(); // toprint passenger details
	string ID_sn();
	
};


#endif /*RESERVATION_H_*/
source File 
#include <string>
#include <iostream>
#include <sstream>
#include "reservation.h"
using namespace std;


//Constructor that initializes the data members to given parameters:
Reservation::Reservation(string psngrName, long psngrPhone, string psngrPassport, bool 	smoke)
	:ID(psngrName)
{
	passenger.setPassengerName(psngrName);
    passenger.setContactNumber(psngrPhone);
    passenger.setPassportNumber(psngrPassport);
    smokerSeat=smoke;
}//end contsteuctor 


Reservation::Reservation(Passenger& psngr, bool smoke)
	
{
   passenger.setPassengerName(psngr.getPassengerName());
   passenger.setPassportNumber(psngr.getPassportNumber());
   passenger.setContactNumber(psngr.getContactNumber());
   smokerSeat=smoke;
}//end consreuctor 

Passenger Reservation::getPassenger()
{
	return this->passenger;
}//end getPassenger Function



 bool Reservation::isSmoker()
 {
	 return smokerSeat;
 }//end function isSmoker
 

void Reservation::printDetails() //function that print the user details 
{
    cout<< "passenger name: "<<passenger.getPassengerName();
	cout<<"passenger Contact Number:"<<passenger.getContactNumber();
	cout<<"Passenger Passport Number :"<<passenger.getPassportNumber();
	cout<<"passenger ID:"<<Reservation::getReservationNumber();
	cout<<" smoking preferences: "<<(isSmoker()?"smoker":"nonsmoker");
} //end function printDetails
i got this problem in the reservation.cpp i cant change any thing in the header file all what i can change is on the cpp file can any one help to solve this problem Confused | :confused: this is line 44:
ID=ss.substr(0,2)+s;
and in header file i have
string ID_sn();
function but im really confused how can i use it int the implementation file (source)
SuggestionRe: error C2678: binary '=' Pin
Maximilien13-Dec-12 7:00
memberMaximilien13-Dec-12 7:00 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 7:18
memberalaaan7313-Dec-12 7:18 
AnswerRe: error C2678: binary '=' Pin
Chris Meech13-Dec-12 7:30
memberChris Meech13-Dec-12 7:30 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 7:52
memberalaaan7313-Dec-12 7:52 
GeneralRe: error C2678: binary '=' Pin
Chris Meech13-Dec-12 8:17
memberChris Meech13-Dec-12 8:17 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 8:59
memberalaaan7313-Dec-12 8:59 
GeneralRe: error C2678: binary '=' Pin
Chris Meech13-Dec-12 9:06
memberChris Meech13-Dec-12 9:06 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 9:24
memberalaaan7313-Dec-12 9:24 
GeneralRe: error C2678: binary '=' Pin
Freak3014-Dec-12 0:48
memberFreak3014-Dec-12 0:48 
AnswerRe: error C2678: binary '=' Pin
Richard MacCutchan13-Dec-12 7:33
mvpRichard MacCutchan13-Dec-12 7:33 
GeneralRe: error C2678: binary '=' Pin
alaaan7313-Dec-12 7:55
memberalaaan7313-Dec-12 7:55 
Questionprocess Pin
messages13-Dec-12 3:45
membermessages13-Dec-12 3:45 
AnswerRe: process Pin
DavidCrow13-Dec-12 4:14
memberDavidCrow13-Dec-12 4:14 
GeneralRe: process Pin
messages13-Dec-12 4:18
membermessages13-Dec-12 4:18 
Questionexporting data from C++ to C Pin
danielsutopo12-Dec-12 15:00
memberdanielsutopo12-Dec-12 15:00 
AnswerRe: exporting data from C++ to C Pin
Richard MacCutchan12-Dec-12 22:35
mvpRichard MacCutchan12-Dec-12 22:35 
GeneralRe: exporting data from C++ to C Pin
danielsutopo15-Dec-12 13:45
memberdanielsutopo15-Dec-12 13:45 

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
Web01 | 2.8.150804.3 | Last Updated 4 Aug 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid