no matching function ....

Hey Guys;

I have a very strange and simple problem. i have a program with a class and constructor and those things. when i want to declare an object for the class, compiler returns this error: no matching function for call to 'xx:xx()'
I really dont know what is the problem.

regards
The error means that you are trying to call a function that does not exist.
Probably your object declaration is incorrect

¿should I really need to ask for your code?
¿should I really need to ask for your code?

Of course not! It wouldn't be nearly as much of a challenge if we could see what the code was, would it?

After all, it's not like we have anything better to do with our time...
hmmm.... but for object declaration it does not have any thing with function existence. here is my code, i just deleted the unnecessary parts:

<code>

#include<iostream>
using namespace std;

class reservation
{
public:
reservation(int C_numberOfPaasengers, string C_source, string C_dest, int C_date, int C_time );
int func_numberOfPaasengers() const;
string func_source() const;
string func_dest() const;
int func_time() const;
int func_date() const;
private:
int numberOfPaasengers;
string source;
string dest;
int time;
int date;
};
//*************************************

int main()
{
reservation reserve;

string M_numberofPassenger;
string M_source;
string M_dest;
int M_time;
int M_date;

int customerChoice;

cout<<" ****** "<<endl;
cout<<"**************************************"<<endl;
cout<<"Welcome to IranAir Reservation System\n";
cout<<"**************************************"<<endl;
cout<<" ****** "<<endl;
customerChoice = mainMenu();


if(customerChoice == 1)
{
cout<<"Please enter number of passengers: ";
cin>>M_numberofPassenger;
cout<<endl;
cout<<"Please enter the source: ";
cin>>M_source;
cout<<endl;
cout<<"please enter the destination: ";
cin>>M_dest;
cout<<endl;
cout<<"please enter the date: ";
cin>>M_date;
cout<<endl;
cout<<"please enter the time: ";
cin>>M_time;
cout<<endl;

reservation reserve(M_numberofpassenger, M_source, M_dest, M_date, M_time);

}

int mainMenu()
{
int opt;
cout<<"please choose from the following options:\n"<<endl;
cout<<"1. ticket reservation\n";
cout<<"2. aircraft status\n";
cout<<"3. routes and prices\n";
cout<<"your choice: ";
cin>>opt;
return opt;
}


//**************************************************
reservation::reservation(int C_numberOfPaasengers, string C_source, string C_dest, int C_date, int C_time )
{
numberOfPaasengers = C_numberOfPaasengers;
source = C_source;
dest = C_dest;
date = C_date;
time = C_time;

}

int reservation::func_numberOfPaasengers() const
{
return numberOfPaasengers;
}

string reservation::func_source() const
{
return source;
}

string reservation::func_dest() const
{
return dest;
}

int reservation::func_time() const
{
return time;
}

int reservation::func_date() const
{
return date;
}
//*****************************************

</code>
reservation(int C_numberOfPaasengers, string C_source, string C_dest, int C_date, int C_time );

When you instantiate your object, you don't use any of these for your constructor. make a default no-arguments instructor or pass these to your constructor when you instantiate your object.
Last edited on
> but for object declaration it does not have any thing with function existence.
When you do reservation reserve; you are trying to call a constructor that takes no parameters. Which you don't have.


By the way, I see that you figure out how to bold text, ¿how is it that you failed to find the code tags and improvised your own?
GRex2595 and ne555, Thanks for your responses, i got it fixed with your hints.

regards
Topic archived. No new replies allowed.