This is a simple program describing two classes- a point and a vector using the point as datatype. I am also trying to use constructors in class point. But whenever I try to declare vector v1 it returns a compiler error. please help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
using namespace std;
class point{
public:
double x,y;
point(double nx, double ny){
x = nx;
y = ny;
cout << "2-para construct";
}
};
class vector{
public:
point start,end;
};
int main(){
point p(3.0,6.0);
vector s; // gives an error
}
|
error for further reference-
classfour.cpp:18:12: error: use of deleted function 'vector::vector()'
18 | vector s;
| ^
classfour.cpp:12:7: note: 'vector::vector()' is implicitly deleted because the default definition would be ill-formed:
12 | class vector{
| ^~~~~~
classfour.cpp:12:7: error: no matching function for call to 'point::point()'
classfour.cpp:6:5: note: candidate: 'point::point(double, double)'
6 | point(double nx, double ny){
| ^~~~~
classfour.cpp:6:5: note: candidate expects 2 arguments, 0 provided
classfour.cpp:3:7: note: candidate: 'constexpr point::point(const point&)'
3 | class point{
| ^~~~~
classfour.cpp:3:7: note: candidate expects 1 argument, 0 provided
classfour.cpp:3:7: note: candidate: 'constexpr point::point(point&&)'
classfour.cpp:3:7: note: candidate expects 1 argument, 0 provided
classfour.cpp:12:7: error: no matching function for call to 'point::point()'
12 | class vector{
| ^~~~~~
classfour.cpp:6:5: note: candidate: 'point::point(double, double)'
6 | point(double nx, double ny){
| ^~~~~
classfour.cpp:6:5: note: candidate expects 2 arguments, 0 provided
classfour.cpp:3:7: note: candidate: 'constexpr point::point(const point&)'
3 | class point{
| ^~~~~
classfour.cpp:3:7: note: candidate expects 1 argument, 0 provided
classfour.cpp:3:7: note: candidate: 'constexpr point::point(point&&)'
classfour.cpp:3:7: note: candidate expects 1 argument, 0 provided