Just saw this question relating to a segmentation fault issue in a C++ class and program.
My question relates to the class definition. Here it is as it was posted:
class A {
int x;
int y;
public:
getSum1() const {
return getx() + y;
}
getSum2() const {
return y + getx();
}
getx() const {
return x;
}
}
None of the answers on that question so far made any mention about the return types of the methods. I'd expect them to be defined like
int getSum1() const { ....
int getSum2() const { ....
int getx() const { ....
Do the int
s have to be there?