1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
class P
{
public:
P(double aX, double aY):coord({aX,aY}) {};
vector<double> getCoord() const;
void init(const P &Pt);
private:
vector<double> coord;
};
vector<double> P::getCoord() const
{
return coord;
}
void P::init(const P &Pt)
{
vector<double> test({1.0,2.0}); //OK
vector<double> test2(Pt.getCoord()); //OK
coord.swap(test); //OK
coord.swap(test2); //OK
// coord(test); //error: no match for call to '(std::vector<double>) (std::vector<double>&)'|
// coord(Pt.getCoord()); //error: no match for call to '(std::vector<double>) (std::vector<double>)':
// coord.swap(Pt.getCoord()); //error: no matching function for call to std::vector<double>::swap(std::vector<double>)'
} |
Partager