Hello..
I'm working on my project.. It's not done yet.. But i wanna debug these errors now first..
Please would someone check them for me.
Thanks..

Here is the interface:

# ifndef MAINMENU_H
# define MAINMENU_H


# include <iostream>
using namespace std;

class MainMenu
{

	public: 

MainMenu();
MainMenu(string the_name);
MainMenu(string the_destanation, string the_departure, string the_date, string the_time);
friend ostream& operator << (ostream& outs,const MainMenu& settings);
friend istream& operator >> (istream& ins,const MainMenu& settings);
friend void display_main_menu ();
int choose_from_main_menu (int choice);
void JOTAKU_LOGO ()const;


	private:
string destanation;
string departure;
string date;
string time;
string name;

};
# endif //MAINMENU_H

Here is the implementation:

# include <iostream>
# include <string>
# include "MainMenu.h"
using namespace std;

MainMenu::MainMenu()
{
destanation="no destanation yet.";
departure="no departure yet.";
date="no date entered yet.";
time="no time yet.";
}

MainMenu(string the_name)
{
name="No name yet.";
}

MainMenu::MainMenu(string the_destanation, string the_departure, string the_date, string the_time)
{
destanation=the_destanation;
departure=the_departure;
date=the_date;
time=the_time;
}

ostream& operator << (ostream& outs,const MainMenu& settings)
{
	outs<<settings.departure
		<<settings.destanation 
		<<settings.date
		<<settings.time;
return outs;

}

istream& operator >> (istream& ins,const MainMenu& settings)
{
	ins >>settings.departure
		>>settings.destanation;
return ins;
}

void MainMenu::display_main_menu ()
{
cout<<"Hello "<<Passenger_name<<" and welcome to J-Otaku-Air travel agency."<<endl
		<<"Please choose a number from the following menu, then press enter to "
		<<"move to the desired page."<<endl<<endl
		<<"1. About J-Otaku-Air"<<endl
		<<"2. Reservations"<<endl
		<<"3. Currency Converter"<<endl
		<<"4. Budget Travels & Special Offers"<<endl
		<<"5. Frequently asked questions"<<endl
		<<"6. Contact us"<<endl
		<<"* Press 0 to exit"<<endl<<endl;
	cin>>num;
	cout<<endl;
}

int MainMenu::choose_from_main_menu (int choice)
{
cin>>choice;
}

void MainMenu::JOTAKU_LOGO () const
{
		cout << "\t\t\t =================    "<<endl;
		cout << "\t\t\t     ||   || || ||    "<<endl;
		cout << "\t\t\t     ||   || || ||    "<<endl;
		cout << "\t\t\t     ||      || ||    "<<endl;
		cout << "\t\t\t \\   ||         ||   "<<endl;
		cout << "\t\t\t  \\  ||              "<<endl;
		cout << "\t\t\t   \\ ||              "<<endl;
		cout << "\t\t\t    \\||  J-Otaku-Air "<<endl;
		cout <<endl;
		cout <<endl;
}

Please provide me with some debuggings.. This is urgent.

Recommended Answers

All 9 Replies

Whats the error ?

I've no idea why is the variable "time" appearing as a purple color! :S

This is the compilation's msg:
1>------ Build started: Project: cs102 proj, Configuration: Debug Win32 ------
1>Compiling...
1>MainMenu.cpp
1>c:\users\fofa\documents\visual studio 2005\projects\cs102 proj\mainmenu.cpp(14) : error C2146: syntax error : missing ')' before identifier 'the_name'
1>c:\users\fofa\documents\visual studio 2005\projects\cs102 proj\mainmenu.cpp(14) : error C2146: syntax error : missing ';' before identifier 'the_name'
1>c:\users\fofa\documents\visual studio 2005\projects\cs102 proj\mainmenu.cpp(14) : error C2059: syntax error : ')'
1>c:\users\fofa\documents\visual studio 2005\projects\cs102 proj\mainmenu.cpp(15) : error C2470: 'the_name' : looks like a function definition, but there is no parameter list; skipping apparent body
1>c:\users\fofa\documents\visual studio 2005\projects\cs102 proj\mainmenu.cpp(19) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>main.cpp
1>Generating Code...
1>Build log was saved at "file://c:\Users\fofa\Documents\Visual Studio 2005\Projects\cs102 proj\Debug\BuildLog.htm"
1>cs102 proj - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I didn't get what is the error. It wants me to insetr a semicolon where I'm not supposed to !

You forgot to add MainMenu::

MainMenu::MainMenu(string the_name)
{
name="No name yet.";
}

I made some alterations.. I by mistake did something..This is the code that needs debugging.. still the same compilation error i've posted above is occuring.

# include <iostream>
# include <string>
# include "MainMenu.h"
using namespace std;

MainMenu::MainMenu()
{
destanation="no destanation yet.";
departure="no departure yet.";
date="no date entered yet.";
time="no time yet.";
}

MainMenu(string the_name)
{
name="No name yet.";
}

MainMenu::MainMenu(string the_destanation, string the_departure, string the_date, string the_time)
{
destanation=the_destanation;
departure=the_departure;
date=the_date;
time=the_time;
}

ostream& operator << (ostream& outs,const MainMenu& settings)
{
	outs<<settings.departure
		<<settings.destanation 
		<<settings.dat
		<<settings.time;
return outs;

}

istream& operator >> (istream& ins,const MainMenu& settings)
{
	ins >>settings.departure
		>>settings.destanation;
return ins;
}

void MainMenu::display_main_menu ()
{
cout<<"Hello "<<name<<" and welcome to J-Otaku-Air travel agency."<<endl
		<<"Please choose a number from the following menu, then press enter to "
		<<"move to the desired page."<<endl<<endl
		<<"1. About J-Otaku-Air"<<endl
		<<"2. Reservations"<<endl
		<<"3. Currency Converter"<<endl
		<<"4. Budget Travels & Special Offers"<<endl
		<<"5. Frequently asked questions"<<endl
		<<"6. Contact us"<<endl
		<<"* Press 0 to exit"<<endl<<endl;
	cin>>choose_from_main_menu;
	cout<<endl;
}

int MainMenu::choose_from_main_menu (int choice)
{
cin>>choice;
}

void MainMenu::JOTAKU_LOGO () const
{
		cout << "\t\t\t =================    "<<endl;
		cout << "\t\t\t     ||   || || ||    "<<endl;
		cout << "\t\t\t     ||   || || ||    "<<endl;
		cout << "\t\t\t     ||      || ||    "<<endl;
		cout << "\t\t\t \\   ||         ||   "<<endl;
		cout << "\t\t\t  \\  ||              "<<endl;
		cout << "\t\t\t   \\ ||              "<<endl;
		cout << "\t\t\t    \\||  J-Otaku-Air "<<endl;
		cout <<endl;
		cout <<endl;
}

Ahaaaa! Omg i feel so stupid right now!
Thank you very much.. I've corrected it and discovered the other eroors myself.. Obly there's one error that I didn't know how to do it.
It's the name when I want to cout it, it says undeclared. It is declared as a privare member. Shall I declare it again??
This is the last code with only one error.

# include <iostream>
# include <string>
# include "MainMenu.h"
using namespace std;

MainMenu::MainMenu()
{
destanation="no destanation yet.";
departure="no departure yet.";
date="no date entered yet.";
time="no time yet.";
}

MainMenu::MainMenu(string the_name)
{
name="No name yet.";
}

MainMenu::MainMenu(string the_destanation, string the_departure, string the_date, string the_time)
{
destanation=the_destanation;
departure=the_departure;
date=the_date;
time=the_time;
}

ostream& operator << (ostream& outs,const MainMenu& settings)
{
	outs<<settings.departure
		<<settings.destanation 
		<<settings.date
		<<settings.time;
return outs;

}

istream& operator >> (istream& ins,const MainMenu& settings)
{
	ins >>settings.departure
		>>settings.destanation;
return ins;
}

void display_main_menu ()
{
cout<<"Hello "<<name<<" and welcome to J-Otaku-Air travel agency."<<endl
		<<"Please choose a number from the following menu, then press enter to "
		<<"move to the desired page."<<endl<<endl
		<<"1. About J-Otaku-Air"<<endl
		<<"2. Reservations"<<endl
		<<"3. Currency Converter"<<endl
		<<"4. Budget Travels & Special Offers"<<endl
		<<"5. Frequently asked questions"<<endl
		<<"6. Contact us"<<endl
		<<"* Press 0 to exit"<<endl<<endl;
	cin>>choose_from_main_menu;
	cout<<endl;
}

int MainMenu::choose_from_main_menu (int choice)
{
cin>>choice;
}

void MainMenu::JOTAKU_LOGO () const
{
		cout << "\t\t\t =================    "<<endl;
		cout << "\t\t\t     ||   || || ||    "<<endl;
		cout << "\t\t\t     ||   || || ||    "<<endl;
		cout << "\t\t\t     ||      || ||    "<<endl;
		cout << "\t\t\t \\   ||         ||   "<<endl;
		cout << "\t\t\t  \\  ||              "<<endl;
		cout << "\t\t\t   \\ ||              "<<endl;
		cout << "\t\t\t    \\||  J-Otaku-Air "<<endl;
		cout <<endl;
		cout <<endl;
}

See the difference between these two :

MainMenu::MainMenu()
{
destanation="no destanation yet.";
departure="no departure yet.";
date="no date entered yet.";
time="no time yet.";
}
 
MainMenu::MainMenu(string the_name)
{
name="No name yet.";
}

In red is the added part.

Yes firstPerson.. I did it thanks to you.. :D
Only one error now. About the variable name. It's the name when I want to cout it, it says undeclared. It is declared as a privare member. Shall I declare it again??

Oh, and please check your inbox (pivate messeges) :)

Private members cannot be output directly because they are private to the class. Nothing outside the class knows it exists. Create a method that returns the value and output via that method:

int getVariableName()
{
    return VariableName;
}

cout << getVariableName(); And please learn to format your code better now. It helps us follow your program and later, as your code gets more complicated, so will you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.