954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

new to c++ need help

i have following code, i am starting a college project and need help

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class ba146{

private:
	int capacity;
	int totalSeatWindow;
	int totalSeatAisle;
	int totalSeatMiddle;	

public:
	string timeOfArrival;
	string timeOfDeparture;
	string departureCity;
	string arrivalCity;
	string flight;
	string seatType;
	int occupiedSeatWindow ;
	int occupiedSeatAisle;
	int occupiedSeatMiddle;

	ba146(){						//Constructor
	
		capacity=120;
		totalSeatWindow=40;
		totalSeatAisle=40;
		totalSeatMiddle=40;
		occupiedSeatWindow=0;
		occupiedSeatAisle=0;
		occupiedSeatMiddle=0;
	};	
	int freeSeat(){
		
		return capacity-(occupiedSeatWindow+occupiedSeatAisle+occupiedSeatMiddle);
	}
	
	
	
};
int main(int argc, char* argv[])
{
	printf("Hello World!\n");
	ba146 fly;
	fly.timeOfArrival="Dublin\n";
	
	cout<<fly.timeOfArrival;
	
	cout<<fly.freeSeat;
	
	return 0;
}

but it gives me a warning , and doesnt print out the 120 like i thought it should.

SmokyMo
Newbie Poster
8 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

>cout<cout<< fly.freeSeat() <<'\n';

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Change this line:
cout<<fly.freeSeat;

to this: cout<<fly.freeSeat();
Remember that freeSeat is a function ;).

Edit: I guess Narue was faster :)

unbeatable0
Junior Poster in Training
90 posts since Sep 2008
Reputation Points: 42
Solved Threads: 13
 

thanks a lot for quick reply, it works . really amatuer mistake but i will get lot of them. java seems so simple compare to c++, maybe thats why they say java is kinder garden stuff

SmokyMo
Newbie Poster
8 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You