Given the definitions below. Each occurrence of a const is a promise to the compiler that the compiler will enforce. What is the promise in each case?

```
const int x = 17; //a)
class A
{
public:
A( );
A(int n):
int f( ) const; // b)
int g(const A& x); // c)
private:
int i;
};
```

In a) the promise is that any code written by the author will not change x.
In b) the promise is that any code written by the author in the definition of A::f( )will not change the state of the calling object.
In c) the promise is that any code written by the author in the definition of A::g(const A&x)will not change the argument in the invocation of this function.

Computer Science & Information Technology

You might also like to view...

In what programming language are macro instructions written?

A) FTP B) HTML C) VBA D) SQL

Computer Science & Information Technology

Discuss the aims of cryptography.

What will be an ideal response?

Computer Science & Information Technology