The following is a definition of 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;
};
```


Error: The class definition for Example has two errors. The first occurs in function
getIncrementedData. The function is declared const, but it modifies the object.
Correction: To correct the first error, remove the const keyword from the definition
of getIncrementedData. [Note: It would also be appropriate to rename this member
function, as get functions are typically const member functions.]
Error: The second error occurs in function getCount. This function is declared static,
so it’s not allowed to access any non-static class member (i.e., data).
Correction: To correct the second error, remove the output line from the getCount definition.

Computer Science & Information Technology

You might also like to view...

Write a program that uses a loop (or loops) to find the address where the Riddler plans to strike.

Holy digits Batman! The Riddler is planning his next caper somewhere on Pennsylvania Avenue. In his usual sporting fashion, he has left the address in the form of a puzzle. The address on Pennsylvania is a four digit number where: • All four digits are different • The digit in the thousands place is three times the digit in the tens place • The number is odd • The sum of the digits is 27 Loop over all the digits in the address. You can generate an integer that corresponds to the digits and check if it meets the constraints, or check if individual digits meet the constraints.

Computer Science & Information Technology

Attempting all possible passwords in attempt to guess the correct one is known as________.

a) scripting b) dictionary attacking c) brute-force cracking d) trial and error

Computer Science & Information Technology

The Alice IDE is often called the Alice property.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Files that are read or written in consecutive order are called random access files.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology