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 the value of c?
What are compound statements?
What is a file descriptor in c?
How the c program is executed?
What are pointers in C? Give an example where to illustrate their significance.
What is a spanning Tree?
What is wrong with this program statement? void = 10;
What is this pointer in c plus plus?
int i=10; printf("%d %d %d", i, i=20, i);
The statement, int(*x[]) () what does in indicate?
What is wrong with this declaration?
What is the ANSI C Standard?
What are the 4 data types?
What is variable initialization and why is it important?
What are terms in math?