Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what is Member function in c++ 2011
#1
Kindly explain a little bit what is member function and non member function and also tell what are member operator and non member operator.
In case of member function of class:
Reply
#2
A non- member function always appear outside of class body. A member function can also appear outside of class body, but the member function must be qualified by the name of its class.
For example:
int student :: myfunction(int a, int b){//member function
------------
}
Int myfunction (int a, int b){ //Non member function
------------------
}
Another difference between member and non member functions is how that are called in the main program.
Consider the following segment of code:
Int main () {
int I;
student std;
I=myfunction (3, 2);// invoking the non-member function
I=std.myfunction (3, 2); // invoking the member function
}
A member operator is typically used when
• The operator modifies the value of the object to which it is applied, requiring it access to the object’s data members. Or,
• The operator requires access to the object’s internal state, represented by data members which are not otherwise accessible (through a public method). In all other instances a nonmember operator is to be preferred. This ensures that there’s that much less chance of the object’s data members getting inadvertently modified (which is only possible from a member method) and at the same time not increasing the size of the object.
The member function of a class takes more than one parameters, depends upon the nature of the function.
Return 0 means that the program ended successfully. When the return statement is used at the end of main, the value 0 indicates that the program has terminated successfully. Any other value is an error code that can be used by whatever program started your program.

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
  why we use inline function if there are simple function available, or what is the spa Vuhelper 0 21,978 05-31-2012, 01:51 AM
Last Post: Vuhelper
  Default Function Argument with example Vuhelper 0 13,328 05-31-2012, 01:47 AM
Last Post: Vuhelper
  What is the difference among calloc function ,malloc function and recalloc function? Vuhelper 0 34,590 05-31-2012, 01:46 AM
Last Post: Vuhelper
  What is Function Overloading in C++ Vuhelper 0 5,399 05-31-2012, 01:45 AM
Last Post: Vuhelper
  offline function in C++ Vuhelper 0 3,624 05-31-2012, 01:42 AM
Last Post: Vuhelper
  i take input from getchar(); function in program in C++ 2012 Vuhelper 0 2,992 05-31-2012, 01:40 AM
Last Post: Vuhelper
  how we used the 1-calloc Function 2- malloc Function 3- free () 4- realloc Function i Vuhelper 1 31,140 05-31-2012, 01:35 AM
Last Post: Vuhelper
  What are the function of IO ports in C++ Vuhelper 0 3,599 05-31-2012, 01:27 AM
Last Post: Vuhelper
  Argc(argument count) and argv(argument value) are used in main function Vuhelper 0 2,031 01-04-2012, 10:42 PM
Last Post: Vuhelper
  array project code c++ 2011 Vuhelper 0 1,273 12-10-2011, 06:32 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)