MC logo

Access Control

  Practice Questions

Consider the following definition:
class Fred
{
     int size;
   public:
     Fred(int i) { size = i; }
     int & Size() { return size; }
};
int m;
int *ip;
const int *cip;
Fred f(14);
Which is legal (will compile), and which is illegal?
  1. *cip = m;

  2. ip = cip;

  3. cip = &m;

  4. m = f.Size();

  5. f.Size() = m;

  6. f.size = m;

  7. Fred f;

<<Bits and Pieces Answer Function Overloading>>