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 calloc malloc realloc in c?
Explain two-dimensional array.
Write a c program to demonstrate character and string constants?
What is the difference between call by value and call by reference in c?
How many types of errors are there in c language? Explain
Is main is a keyword in c?
write a program to rearrange the array such way that all even elements should come first and next come odd
What's the right way to use errno?
What is the difference between #include and #include 'file' ?
What is the maximum no. of arguments that can be given in a command line in C.?
Tell me what is the purpose of 'register' keyword in c language?
Explain the difference between structs and unions in c?
How are variables declared in c?
How can you increase the allowable number of simultaneously open files?
How is null defined in c?