class foo {
public:
static int func(const char*& p) const;
};
This is illegal, why?
Answer Posted / abdur rab
A member function can be declard as Const by considering
the fact that they contain a hidden "this pointer" to be a
pointer to a const object. However Static methods do not
have the "this pointer", and hence can't be const or
virtual.
Hence it is illegal to declare a static function as const.
The C++ language standard stipulates at section 9.4.1
that "[...] A static
member function shall not be declared const
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is a stream water?
what are the advantages of a macro over a function?
What is the difference between a free-standing and a hosted environment?
what are non standard function in c
Who is the main contributor in designing the c language after dennis ritchie?
Write a program to check prime number in c programming?
What happens if you free a pointer twice?
What is the difference between %d and %i?
What is a method in c?
Can an array be an Ivalue?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What is the difference between near, far and huge pointers?
Explain the difference between #include "..." And #include <...> In c?
Tell me what are bitwise shift operators?
How do I convert a string to all upper or lower case?