class foo {
public:
static int func(const char*& p) const;
};

This is illegal, why?

Answer Posted / jaroosh

This code is obviously wrong, and here is why :
declaring a method to be const, means :
this method cannot CHANGE values of any member variables,
but while the method already is static, it has no means of
changing values of member variables, because simply - it
cannot see them (its belongs to a CLASS, not any specific
OBJECT).

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

differentiate built-in functions and user – defined functions.

636


about c language

1608


What are types of preprocessor in c?

624


When should the register modifier be used? Does it really help?

622


Which node is more powerful and can handle local information processing or graphics processing?

831






What is a nested loop?

653


write a proram to reverse the string using switch case?

2473


Explain setjmp()?

662


What are the types of i/o functions?

685


What is the purpose of 'register' keyword?

694


Why is c so popular?

655


7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

2229


What are the restrictions of a modulus operator?

641


What are the two types of functions in c?

575


What is atoi and atof in c?

620