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's a good way to check for "close enough" floating-point equality?
Why is not a pointer null after calling free?
Why can’t constant values be used to define an array’s initial size?
What is new line escape sequence?
What are compound statements?
a program that can input number of records and can view it again the record
Explain the use of 'auto' keyword
Explain how can you check to see whether a symbol is defined?
What is external variable in c?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
Why shouldn’t I start variable names with underscores?
How do we print only part of a string in c?
What is character set?
What are the 4 types of programming language?
Explain what is the difference between a string and an array?