recieving this error
i know its something to do with declaration and definition mis-match but i cant seem to put my finger on it.
Any help would be appreciated :)
IntelliSense: declaration is incompatible with "<error-type>
Airport::getDetails(std::string)" (declared at line 16 of "z:\documents\visual studio 2010\projects\oo_cw\oo_cw\Airport.h")
z:\documents\visual studio 2010\projects\oo_cw\oo_cw\airport.cpp 50 22 OO_CW
Heres my header file and cpp file
header
#pragma once
#include <string>
#include "std_lib_facilities.h"
class Airport
{
public:
Airport();
~Airport(void);
//Modifiers
void setName(string);
void addConnection(string,double,double);
void setTax(double);
//Accessors
string getName();
connections getDetails(string) const ;
double getTax();
private:
string name;
Vector<connections> destinations;
double tax;
};
cpp
#include "Airport.h"
#include <string>
#include "std_lib_facilities.h"
using namespace std;
struct connections {
string destName;
double price;
double time;
};
Airport::Airport()
{
name = "";
tax = 0.0;
};
Airport::~Airport(void)
{
};
void Airport::setName(string airportName){
Airport::name = airportName;
}
void Airport::setTax(double airportTax){
tax = airportTax;
}
void Airport::addConnection(string conName, double conPrice, double conTime){
connections newConnection;
newConnection.destName = conName;
newConnection.price = conPrice;
newConnection.time = conTime;
destinations.push_back(newConnection);
}
string Airport::getName(){
return name;
}
double Airport::getTax(){
return tax;
}
connections Airport::getDetails(string reqName) const {
for(int i =0;i<destinations.size();i++){
if(destinations[i].destName==reqName){
return destinations[i];
}
}
}
connections
definition above class Airport
definition in the header file.Airport::getDetails()
must return something for the trivial case, where destinations.size() == 0
, (see code below).std::vector
in the place of Vector
?connections Airport::getDetails(string reqName) const {
for (int i = 0; i<destinations.size(); i++){
if (destinations[i].destName == reqName){
return destinations[i];
}
}
return connections{"", 0.0, 0.0};
}