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 difference between memcpy and memmove?
What are nested functions in c?
What does c mean in standard form?
Should I learn data structures in c or python?
Can we access array using pointer in c language?
What is cohesion and coupling in c?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
What are different types of operators?
What is the auto keyword good for?
How will you write a code for accessing the length of an array without assigning it to another variable?
What is the difference between break and continue?
What are global variables and explain how do you declare them?
What does stand for?
What is difference between static and global variable in c?
What are the key features in c programming language?