A
aravandor
I'm a C++ beginner coming from Java and VB.Net
I know that this is an elementary question, but I'm stumped. I'm
trying to make a coordinate class to store 2 Dimensional points and a
Rectangle class that is defined by two of these coords.
I'm using the mingw32 compiler with Bloodshed's DevC++ IDE. When I
compile this code, I keep getting the following errors from the mingw32
compiler:
no matching function for call to `coord::coord ()'
candidates are: coord::coord(int, int)
Here's the code:
class coord {
public:
int x;
int y;
coord(int a, int b) {
x = a;
y = b;
}
coord(const coord& rhs) {
x = rhs.x;
y = rhs.y;
}
};
class rectangle {
public:
coord c1;
coord c2;
int color;
rectangle (coord a, coord b, int c = 0) {
c1 = a;
c2 = b;
color = c;
}
rectangle(int x1, int y1, int x2, int y2, int c = 0) {
c1 = coord(x1,y1);
c2 = coord(x2,y2);
color = c;
}
void draw() {
rectfill(screen, c1.x, c1.y, c2.x, c2.y, color);
}
};
I know I'm making a stupid mistake here. Can anyone help me out?
I know that this is an elementary question, but I'm stumped. I'm
trying to make a coordinate class to store 2 Dimensional points and a
Rectangle class that is defined by two of these coords.
I'm using the mingw32 compiler with Bloodshed's DevC++ IDE. When I
compile this code, I keep getting the following errors from the mingw32
compiler:
no matching function for call to `coord::coord ()'
candidates are: coord::coord(int, int)
Here's the code:
class coord {
public:
int x;
int y;
coord(int a, int b) {
x = a;
y = b;
}
coord(const coord& rhs) {
x = rhs.x;
y = rhs.y;
}
};
class rectangle {
public:
coord c1;
coord c2;
int color;
rectangle (coord a, coord b, int c = 0) {
c1 = a;
c2 = b;
color = c;
}
rectangle(int x1, int y1, int x2, int y2, int c = 0) {
c1 = coord(x1,y1);
c2 = coord(x2,y2);
color = c;
}
void draw() {
rectfill(screen, c1.x, c1.y, c2.x, c2.y, color);
}
};
I know I'm making a stupid mistake here. Can anyone help me out?