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's a good way to check for "close enough" floating-point equality?

632


Why is not a pointer null after calling free?

600


Why can’t constant values be used to define an array’s initial size?

840


What is new line escape sequence?

814


What are compound statements?

633






a program that can input number of records and can view it again the record

1488


Explain the use of 'auto' keyword

683


Explain how can you check to see whether a symbol is defined?

665


What is external variable in c?

619


What would happen to X in this expression: X += 15; (assuming the value of X is 5)

1310


Why shouldn’t I start variable names with underscores?

629


How do we print only part of a string in c?

591


What is character set?

687


What are the 4 types of programming language?

589


Explain what is the difference between a string and an array?

640