Missing Constructor for a vector

Hi I am trying to debug a program I was given and I trying to wrap my head around this program and compile it. I am having an error stating it is missing a constructor initialization for 'Vector'
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <vector> 

using namespace std;

class Point {
private:
    double x;
    double y;
public:
    double get_x() { return x; }
    double get_y() { return y; }
    bool set_x(double arg) {
        x = arg;
        return true;
    }
    bool set_y(double arg) {
        y = arg;
        return true;
    }
    Point() : x(0), y(0) {}
    Point(double argx, double argy) : x(argx), y(argy) {
    }
};


class Vector {
private:
    Point A;
    Point B;
public:
    Vector(){}
    Point get_A() { return A; }
    Point get_B() { return B; }
    Vector(const Point &arg1, const Point &arg2) : A(arg1), B(arg2)
    {
        //this->A = arg1;
        //this->B = arg2;
        //A = arg1;
        //B = arg2;
    }
    void set_A(const Point &arg) {
        A = arg;
    }
    void set_B(const Point &arg) {
        B = arg;
    }
    static Vector add_vector(const Vector &vector1, const Vector &vector2) {
        if (&vector1.B != &vector2.A) {
            Vector rval;
            return rval;
        }
        
        Point one = vector1.A;
        Point two = vector2.B;
        
        Vector newvector(one, two);
        //newvector.A = one;
        //newvector.B = two;
        return newvector;
        
    }
    Vector add_vector(const Vector &arg) {
        // Type of this?  Vector *; These three lines are equivalent:
        //Point one = this->A;
        //Point one = (*this).A;
        Point one = A;
        
        Point two = arg.B;
        
        Vector newvector(one, two);
        //newvector.A = one;
        //newvector.B = two;
        return newvector;
    }

};


int main() {
    Vector v;
    cout << "(" << v.get_A().get_x() << ", " << v.get_A().get_y() << "),\n" <<
    "(" << v.get_B().get_x() << ", " << v.get_B().get_y() << ")\n";

this is where my error is
1
2
 
    Vector v1(1,2), v2(2,3);

1
2
3
4
5
6
    Vector res = Vector::add_vector(v1, v2);
    cout << "(" << res.get_A().get_x() << ", " << res.get_A().get_y() << "),\n" << 
    "(" << res.get_B().get_x() << ", " << res.get_B().get_y() << ")\n";
    
}
Last edited on
You don't have a Vector constructor that takes two arguments of type int. Which constructor were you expecting it to use?
Topic archived. No new replies allowed.