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

What are keywords in c with examples?

604


What does typeof return in c?

639


Can we use any name in place of argv and argc as command line arguments?

610


What is a list in c?

621


Why do we write return 0 in c?

555






Explain how do you declare an array that will hold more than 64kb of data?

904


can any one provide me the notes of data structure for ignou cs-62 paper

1706


Why we write conio h in c?

567


I came across some code that puts a (void) cast before each call to printf. Why?

678


For what purpose null pointer used?

606


How main function is called in c?

629


I heard that you have to include stdio.h before calling printf. Why?

588


What is clrscr in c?

678


How can I do peek and poke in c?

621


What is a nested loop?

651