| | |
new to c++ need help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2007
Posts: 8
Reputation:
Solved Threads: 0
i have following code, i am starting a college project and need help
but it gives me a warning , and doesnt print out the 120 like i thought it should.
C++ Syntax (Toggle Plain Text)
#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; }
>cout<<fly.freeSeat;
freeSeat is a function. Even if there are no arguments, you still need the (empty) parameter list:
freeSeat is a function. Even if there are no arguments, you still need the (empty) parameter list:
C++ Syntax (Toggle Plain Text)
cout<< fly.freeSeat() <<'\n';
Last edited by Narue; Apr 15th, 2009 at 1:32 pm.
New members chased away this month: 4
![]() |
Other Threads in the C++ Forum
- Previous Thread: Confuse with traverse
- Next Thread: How to make Visual Studio 2005 C++ MSI?
Views: 241 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll dynamic encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linker linux loop looping loops map math matrix memory microsoft newbie news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort stream string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets







.