我想创建一个自定义类型的构造函数,但由于某种原因,它试图打电话,我在猜测是另一个类的构造函数定义中的构造函数。无法找到任何符合我在其他任何问题中遇到的相同症状的东西,因为我可能不知道我在找什么。构造函数与自定义类作为参数,抛出'没有匹配的函数调用...'
当我打电话:
LatLngBounds clusterBounds(&boundsNorthEast, &boundsSouthWest);
在main.cpp中
,在LatLngBounds.cpp我得到 “没有找到调用“经纬度匹配功能可按:经纬度()” 就行抛出两次:
LatLngBounds::LatLngBounds(LatLng &newSouthWest, LatLng &newNorthEast)
任何人有任何想法?
德鲁J.索内。
IDE:Xcode的3.2(靶向调试10.5)
OS:OSX 10.6
编译器:GCC 4.2
拱:x86_64的
main.cpp中:
std::vector<std::string> argVector;
... fill up my argVector with strings..
vector<double> boundsVector = explodeStringToDouble(argVector[i]);
LatLng boundsNorthEast(0, boundsVector[0], boundsVector[1]);
LatLng boundsSouthWest(0, boundsVector[2], boundsVector[3]);
LatLngBounds clusterBounds(&boundsNorthEast, &boundsSouthWest);
LatLngBounds.h
#ifndef __LATLNGBOUNDS
#define __LATLNGBOUNDS
#include "LatLng.h"
class LatLngBounds {
private:
LatLng northEast;
LatLng southWest;
public:
LatLngBounds(LatLng&,LatLng&);
};
#endif
LatLngBounds.cpp
#include "LatLngBounds.h"
#include "LatLng.h"
LatLngBounds::LatLngBounds(LatLng &newSouthWest, LatLng &newNorthEast)
{
this->southWest = newSouthWest;
this->northEast = newNorthEast;
};
LatLng.h
#ifndef __LATLNGDEF
#define __LATLNGDEF
class LatLng {
public:
LatLng(int,double,double);
private:
double lat, lng;
int id;
};
#endif
LatLng.cpp
#include "LatLng.h"
LatLng::LatLng(int newId, double newLat, double newLng)
{
/* Grab our arguments */
id = newId;
lat = newLat;
lng = newLng;
};
太棒了。这也是函数调用中的&,但这是我无法找到的。谢谢。 – Drew 2009-11-11 07:25:16