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.
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;
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;
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;
}
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.
> 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?