A
A. Farber
Hi,
could someone please provide a gentle explanation
(for a C-programmer trying C++) why doesn't the following
code compile? (I've tried MS Visual C++ 6 on Win as well).
Also what is the mentioned Circle::Circle (const Circle &)
for? I remember reading something about it before, but
can't find that information now...
Thank you
Alex
bolinux12:afarber {92} cat shapes.cpp
#include <iostream>
using namespace std;
class Shape {
int x, y;
public:
Shape(int x, int y) { }
};
class Circle: public Shape {
};
int main() {
Circle c(100, 120);
return 0;
}
bolinux12:afarber {93} g++296 -o shapes shapes.cpp
shapes.cpp:11: base `Shape' with only non-default constructor in class
without a constructor
shapes.cpp: In function `int main ()':
shapes.cpp:14: no matching function for call to `Circle::Circle (int,
int)'
shapes.cpp:11: candidates are: Circle::Circle (const Circle &)
could someone please provide a gentle explanation
(for a C-programmer trying C++) why doesn't the following
code compile? (I've tried MS Visual C++ 6 on Win as well).
Also what is the mentioned Circle::Circle (const Circle &)
for? I remember reading something about it before, but
can't find that information now...
Thank you
Alex
bolinux12:afarber {92} cat shapes.cpp
#include <iostream>
using namespace std;
class Shape {
int x, y;
public:
Shape(int x, int y) { }
};
class Circle: public Shape {
};
int main() {
Circle c(100, 120);
return 0;
}
bolinux12:afarber {93} g++296 -o shapes shapes.cpp
shapes.cpp:11: base `Shape' with only non-default constructor in class
without a constructor
shapes.cpp: In function `int main ()':
shapes.cpp:14: no matching function for call to `Circle::Circle (int,
int)'
shapes.cpp:11: candidates are: Circle::Circle (const Circle &)