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
Why do some versions of toupper act strangely if given an upper-case letter?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
Can you define which header file to include at compile time?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
If errno contains a nonzero number, is there an error?
What is the purpose of the preprocessor directive error?
What is the benefit of using #define to declare a constant?
Is array a primitive data type in c?
Explain why c is faster than c++?
Explain how do you list a file’s date and time?
What is the role of && operator in a program code?
Can we use visual studio for c?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
What are the types of arrays in c?