Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What are constant members functions in c++ 2011
#1
What are constant members functions
Reply
#2
Constant member functions are those functions that can not modified the object state. Constant member functions are “read only”. Constant data member function can not change data member. To declare a constant member function, place the const keyword after the closing parenthesis of the argument list. The const keyword is required in both the declaration and the definition.
Syntax:
class className{
returnValue Function() const;
};
Definition:
returnValue className:: function() const{
}
Example:
class Student{
public:
int getRollNo() const {
return rollNo;
}
};

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how often do we require to use inline functions and macros. their importance in c++ Vuhelper 0 8,462 05-31-2012, 01:49 AM
Last Post: Vuhelper
  what does the term Constant time mean in c++ 2012? Vuhelper 0 1,890 01-04-2012, 10:14 PM
Last Post: Vuhelper
  array project code c++ 2011 Vuhelper 0 1,273 12-10-2011, 06:32 PM
Last Post: Vuhelper
  factorial in C++ code 2011 Vuhelper 0 943 12-10-2011, 06:31 PM
Last Post: Vuhelper
  Is void used only with functions? If yes than why? Vuhelper 0 2,500 11-05-2011, 05:10 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,025 11-05-2011, 05:05 PM
Last Post: Vuhelper
  What is the Thing Queue? in c++ 2011 Vuhelper 0 1,785 11-05-2011, 05:02 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,721 11-05-2011, 05:01 PM
Last Post: Vuhelper
  How to write a summation in a sequence? C++ 2011-12 Vuhelper 2 1,355 09-19-2011, 04:53 AM
Last Post: Xpert
  GetPixel problem in c++ 2011-12 Vuhelper 0 2,504 09-18-2011, 07:12 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)