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
What is the use of getch ()?
how do you programme Carrier Sense Multiple Access
Which are low level languages?
Explain what is the concatenation operator?
What are header files why are they important?
What is a stream water?
How can you restore a redirected standard stream?
What is the difference between if else and switchstatement
Which of these functions is safer to use : fgets(), gets()? Why?
How reliable are floating-point comparisons?
Why does everyone say not to use scanf? What should I use instead?
What does printf does?
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
What are c preprocessors?
What does a pointer variable always consist of?