class foo {
public:
static int func(const char*& p) const;
};

This is illegal, why?

Answer Posted / rafal dzbek

the 2nd const used in the example is invalid because it can
be used only with member functions which have a hidden
argument called this. The 2nd const would be applied to
this.
The funct is static member function so it hasn't any this
pointer.

Actually it is not obvious what is exactly inccorect.
We can remove static keyword, then we get syntactically
correct class definition, or we can remove 2nd const and
again the class can be considered valid.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

1928


FILE PROGRAMMING

1779


What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

677


what do u mean by Direct access files? then can u explain about Direct Access Files?

1642


Why clrscr is used in c?

587






What is malloc calloc and realloc in c?

670


write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);

1848


Define and explain about ! Operator?

615


What is the advantage of a random access file?

639


What is dynamic variable in c?

567


What are the loops in c?

593


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

643


Explain what are multibyte characters?

629


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

981


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

632