C++ Student needs help. Please look at code and explain what/why the errors.

mrthom2
mrthom2 used Ask the Experts™
on
I know this is kin of log because I included error messages, but if you would print it out and take a look I would be greatfull.  I'm sure it is some dumb mistake(s), but I sure don't see them.  Thank you
//this is main cpp file

#include<iostream>
#include "H_Menu.h"

using namespace std;

int main()
{
      Menu menu;
      menu.displayMenu; //arrow points this line
      return 0;
}

error msg: cpp(15) : warning C4551: function call missing argument list

//this is class file

#ifndef H_Airline
#define H_Airline

#include <iostream>
#include <iomanip>

class Seats
{
public:
      Seats();
      void showSeats();
      void fClass();
      void nsClass();
      void eClass();
      void reserved();
      void displayMenu();

private:
      int i, j;
      int ROW, COLUMN;
      int row;
      char col;
      int setcol;
      int sect1, sect2, sect3;
      char seatArray[14][7];

};

Seats::Seats()
{
      ROW = 14;
      COLUMN = 7;
      row = 0;
      col = 0;
      setcol = 0;
      sect1 = 3;
      sect2 = 8;
      for(i = 0; i < ROW; i++)
            for(j = 0; j < COLUMN; j++)
                  seatArray[i][j] = 0;
      fClass();
      nsClass();
      eClass();
}

void Seats::fClass()
{//Begin First Class Rows
      for(i = 1; i < sect1; i++)
            for(j = 1; j < COLUMN; j++)
                  seatArray[i][j] = (char) 70;
}//End First Class Rows

void Seats::nsClass()
{//Begin Non-Smoking Rows
      for(i = sect1; i < sect2; i++)
            for(j = 1; j < COLUMN; j++)
                  seatArray[i][j] = (char) 78;
}//End Non-Smoking Rows

void Seats::eClass()
{//Begin Economy Rows
      for(i = sect2; i < ROW; i++)
            for(j = 1; j < COLUMN; j++)
                  seatArray[i][j] = (char) 83;
}//End Economy Rows

void Seats::showSeats()
{//Begin Show Seats
      cout<<'---------------------------------\n';
      <<setw(8)<<(char) 65;
            for(j = 1; j < COLUMN - 1; j++)
                  cout<<setw(5)<<(char) 65 + j;
            cout<<endl<<endl;
            for(i = 1; i < ROW; i++)
                  cout<<"Row "<<setw(3)<<left<<i;
            for(j = 1; j < COLUMN; j++)
                  cout<<setw(5)<<seatArray[i][j];
            if(j % 6 == 0)
                  cout<<'\n';
            cout<<endl;
}//End Show Seats

void Seats::reserved()
{//Begin Reserved Seats
      cout<<"Enter a row number and a column number.";
      cin>>row>>col;
      setcol = toupper(col) - 64;
      if(seatArray[row][column] = 'X')
            cout<<"The seat that you have chosen is already taken.\n"
                  <<"Please choose again."<<endl;
      else
            seatArray[row][setcol] = (char) 88;
}

#endif

//error msgs:h(71) : error C2065: 'cout' : undeclared identifier
h(71) : error C2015: too many characters in constant
h(71) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
h(72) : error C2143: syntax error : missing ';' before '<<'
h(74) : error C2065: 'setw' : undeclared identifier
h(74) : warning C4554: '<<' : check operator precedence for possible error; use parenthese
h(74) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
h(75) : error C2065: 'endl' : undeclared identifier
h(75) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
h(77) : error C2297: '<<' : illegal, right operand has type 'char [5]'
h(77) : error C2065: 'left' : undeclared identifier
h(79) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
h(81) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
h(82) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
h(87) : error C2297: '<<' : illegal, right operand has type 'char [40]'
h(88) : error C2065: 'cin' : undeclared identifier
h(88) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
h(90) : error C2065: 'column' : undeclared identifier
h(92) : error C2297: '<<' : illegal, right operand has type 'char [49]'

//this is menu file

#ifndef H_Menu
#define H_Menu

#include<iostream>
#include "H_Airline.h"

using namespace std;

class Menu
{
public:
      Menu();
      void menuSelect();
      void displayMenu();

private:
      Seats seating;
      bool notDone;
      int choice;
      enum menu{FIRST_CLASS = 1,
                    NON_SMOKING,
                    ECONOMY,
                    EXIT};
};

Menu::Menu()
{
      notdone = true;
      choice = 0;
}

void Menu::menuSelect()
{
      while(notdone)
      {
            cout<<"\n\tEnter as selection number: ";
            cin>>choice;
            cout<<endl;

            switch(choice)
            {
                  case FIRST_CLASS:
                  {
                        seating.displayMenu();
                        seating.reserved();
                        displayMenu();
                        notdone = false;
                        break;
                  }
                  case NON_SMOKING:
                  {
                        seating.displayMenu();
                        seating.reserved();
                        displayMenu();
                        notdone = false;
                        break;
                  }
                  case ECONOMY:
                  {
                        seating.displayMenu();
                        seating.reserved();
                        displayMenu();
                        notdone = false;
                        break;
                  }
                  case EXIT:
                  {
                        cout<<"\n\tThank You...Come Again.\n";
                        notdone = false;
                        break;
                  }
                  default:
                  {
                        cout<<"\n\tInvalid selection! Please choose again. \n\n";
                        break;
                  }
            }
      }
}

void Menu::displayMenu()
{
      cout<<"\n\t--------------Seating Menu--------------\n\t";
      cout<< FIRST_CLASS                  << ")      FirstClass\n\t";
      cout<< NON_SMOKING                  << ")      Non-Smoking\n\t";
      cout<< ECONOMY                        << ")      Economy\n\t";
      cout<< EXIT                              << ")      Exit\n\t";
            menuSelect();
}
#endif

//error msgs:(30) : error C2065: 'notdone' : undeclared identifier
(38) : error C2872: 'cout' : ambiguous symbol
(38) : error C2297: '<<' : illegal, right operand has type 'char [30]'
(39) : error C2872: 'cin' : ambiguous symbol
(39) : warning C4552: '>>' : operator has no effect; expected operator w
(40) : error C2872: 'cout' : ambiguous symbol
(40) : error C2872: 'endl' : ambiguous symbol
(40) : warning C4552: '<<' : operator has no effect; expected operator w
(70) : error C2872: 'cout' : ambiguous symbol
(70) : error C2297: '<<' : illegal, right operand has type 'char [27]'
(76) : error C2872: 'cout' : ambiguous symbol
(76) : error C2297: '<<' : illegal, right operand has type 'char [45]'
(85) : error C2872: 'cout' : ambiguous symbol
(85) : error C2297: '<<' : illegal, right operand has type 'char [45]'
(86) : error C2872: 'cout' : ambiguous symbol
(86) : error C2297: '<<' : illegal, right operand has type 'char [15]'
(87) : error C2872: 'cout' : ambiguous symbol
(87) : error C2297: '<<' : illegal, right operand has type 'char [16]'
(88) : error C2872: 'cout' : ambiguous symbol
(88) : error C2297: '<<' : illegal, right operand has type 'char [12]'
(89) : error C2872: 'cout' : ambiguous symbol
(89) : error C2297: '<<' : illegal, right operand has type 'char [9]'
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
>>error msg: cpp(15) : warning C4551: function call missing argument list

you need to have an argument list when calling a function, even if it is empty. like:

menu.displayMenu();  //or whatever arguments displayMenu takes.

you should include the line "using namespace std;" after the include statements for the H_Airline file(seat class)

cout-- statements must be in double quotes(i think) for strings.  like:

cout<<"---------------------------------\n"; //and when the semi-colon is seen, the cout statement is done...you may want to do soemthing like this here:

cout<<"---------------------------------" << endl << 
setw(8)<<(char) 65;


your notDone variable was declared spelled notDone, with a capital D, then you use it with a small d.

I'm not sure why all your cout statements aren't working, let me think about that.

Commented:
maybe a space between #include and <iostream>
#include <iostream>  //?? i don't know ??//

Commented:
First separate the code and the definitions.
Put definitions in a header (.h) file and the implementation in an implementation (.cpp or .cxx) file.

Use
#ifndef H_Airline
#define H_Airline
.....
#endif

In your header file only !


In example
in the header file (menu.h) write:

#ifndef H_menu
#define H_menu

class Menu
{
public:
     Menu();
     void menuSelect();
     void displayMenu();

private:
     Seats seating;
     bool notDone;
     int choice;
     enum menu{FIRST_CLASS = 1,
                 NON_SMOKING,
                 ECONOMY,
                 EXIT};
};
#endif // H_menu


And in the implementation file (menu.cpp)include menu.h and implement the necesary member functions:

Menu::Menu()
{
     notdone = true;
     choice = 0;
}

void Menu::menuSelect()
{
     while(notdone)
     {
          cout<<"\n\tEnter as selection number: ";
          cin>>choice;
          cout<<endl;

          switch(choice)
          {
               case FIRST_CLASS:
               {
                    seating.displayMenu();
                    seating.reserved();
                    displayMenu();
                    notdone = false;
                    break;
               }
               case NON_SMOKING:
               {
                    seating.displayMenu();
                    seating.reserved();
                    displayMenu();
                    notdone = false;
                    break;
               }
               case ECONOMY:
               {
                    seating.displayMenu();
                    seating.reserved();
                    displayMenu();
                    notdone = false;
                    break;
               }
               case EXIT:
               {
                    cout<<"\n\tThank You...Come Again.\n";
                    notdone = false;
                    break;
               }
               default:
               {
                    cout<<"\n\tInvalid selection! Please choose again. \n\n";
                    break;
               }
          }
     }
}

void Menu::displayMenu()
{
     cout<<"\n\t--------------Seating Menu--------------\n\t";
     cout<< FIRST_CLASS               << ")     FirstClass\n\t";
     cout<< NON_SMOKING               << ")     Non-Smoking\n\t";
     cout<< ECONOMY                    << ")     Economy\n\t";
     cout<< EXIT                         << ")     Exit\n\t";
          menuSelect();
}

If then you still have problems post them
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Commented:
hoookaay... here we go:

In H_Airline.H, line 71, use Double quotes -> "" instead of single quotes ''   ..  single quotes are for a single character. Double quotes are for strings. So your modified line would be:
     cout<< "---------------------------------\n";
________________________________________________________

In H_Airline.h, change your declarations by adding a .h to them so they become:

#include <iostream.h>
#include <iomanip.h>

and add the line

#include <ctype.h>

this is for the function toupper()
_________________________________________________________

In H_Arline.h line 77 which is
               cout<<"Row "<<setw(3)<<left<<i;
You use "left" .. but this is not defined.. remove it or clarify what you mean by left.

___________________________________________________

Same file, lines 88-90
     cin>>row>>col;
     setcol = toupper(col) - 64;
     if(seatArray[row][column] = 'X')

You are using column, although your cin says "col".. change it to seatArray[row][col]

_______________________________

In H_Menu.h

In line 18 you wrote
     bool notDone;

Change it to      bool notdone;
because later on in the program you use a lowecase d in "notdone" .. remember that C is case sensitive and the words "notDone" and "notdone" are different.

_______________________________________________

In H_menu.h line 8

remove the line:

using namespace std

___________________________________________

In main.cpp

change the line

     menu.displayMenu; //arrow points this line

to

     menu.displayMenu(); //arrow points this line

Never forget the () when calling a function.

___________________________________________

In main.cpp change your includes to

#include <iostrem.h>   // don't forget the .h

and remove the line
using namespace std;
______________________

And finally, this might be a logical problem or something you simple have to add:

you are calling seating.displayMenu() ... but seating is of Class Seats, and Seats does not have a member function called displayMenu which will cause you linker errors...

__________________

That's it! In general you have small errors which you need to pay attention to... don't rush things and you'll evenetually get it.. good luck.
btw fork, it duznt matter whether you write: #include<iostream.h> or #include <iostream.h> .......

Commented:
i didn't think so...thx!
include file iostream.h in your header file
"H_Menu.h"
and then try compiling

Author

Commented:
Thanks fork.  I don't know how to award you the points, but you get them.

Commented:
This question didn't show any activity for more than 21 days. I will ask Community Support to close it unless you finalize it yourself within 7 days.
You can always request to keep this question open. But remember, experts can only help if you provide feedback to their comments.
Unless there is objection or further activity,  I will suggest to accept

    "__fork__"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
========
Werner
Force accepted

** Mindphaser - Community Support Moderator **

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial