The following is a proposed definition of a class Example:
class Example {
public:
Example(int y = 10) : data(y) {}
int getIncrementedData() const {
return ++data;
}
static int getCount() {
cout << "Data is " << data << endl;
return count;
}
private:
int data;
static int count;
};
What is the correction to the following error?
Error: The function getIncrementedData is declared const, but it modifies the object.
Correction: Remove the const keyword from the definition of getIncrementedData.
Correction: Replace int with static int in the declaration of getIncrementedData.
Correction: Rename the member function getIncrementedData, as get functions are typically const
member functions.
Correction: Remove the type int from the declaration of getIncrementedData.