Nesting of Member Function
#include
using namespace std;
class set
{
int m,n;
public:
void input(void);
void display(void);
void largest(void);
};
int set :: largest(void)
{
if(m >= n)
return(m);
else
return(n);
}
void set :: input(void)
{
cout << "Input value of m and n"<<"\n";
cin >> m>>n;
}
void set :: display(void)
{
cout << "largest value=" << largest() <<"\n";
}
int main()
{
set A;
A.input();
A.display();
return 0;
}
The output of program would be:
Input value of m and n
25 18
Largest value=25
This is not a correct program and its showing some errors.
ReplyDeleteu have to replace void largest(void); with int largest(void);
ReplyDeletewhat is nesting in this??
ReplyDeleteHere void input()
Deletevoid dislpay() and
void largest() are declared in the public specifier of class 'set' instead of declaring outside
Here they've used :: ie scope resolution operator
This is called nesting of member function
He is calling largest() function inside the display() function, That is called nesting of member function.
DeleteHe is calling largest() function inside the display() function, That is called nesting of member function. Visit for C, C++ , HTML And CSS Proejcts
ReplyDelete
DeleteSend me your watsapp no.
tx sir
Deletethi program have some errors..!!
ReplyDeletethere are some errors
ReplyDeleteA member function of a class can be called only by an object of that class using a dot operator
ReplyDeletewhat is the meaning of this line
ReplyDeleteplease explain me
this means when u are calling member function or simply say that function first u need to write object name then (.) dot operator and then writing function name i.e object.function name
Deletewhat is the meaning of this line
ReplyDeleteplease explain me
It's a simple function call dude,not a nesting...brush up
ReplyDeleteIts correct and perfect example of nested function, only the mistake that has been done with this program is, in it's declaration part. In function declaration function largest(),data type used as void and this has been defined with int., that is wrong. So, Function declaration should also be
ReplyDeleteint largest();
You are right dude...thats the only error .
DeleteI don't think it's a nesting of member function
ReplyDeleteSomething is wrong in this program
ReplyDeleteThis program has errors
ReplyDeletethis program has create a error
ReplyDeleteexample of error program
ReplyDeleteHeader file not declaration correct
ReplyDeleteAnd check this program
This program is working no one correctly used the program
ReplyDeleteIf I'm not wrong then these is an outside the class definition and not nesting of members because in nesting of members we are using the functions inside only but anyway correct me if I wrong..
ReplyDeleteturbo c++
ReplyDeleteturbo c++ download
download turbo c++
turbo c++ for windows 10
turbo c++ download for windows 10
turbo c++ for windows 7
turbo c++ free download
turbo c++ 4.5 for windows 10
turbo c++ download for pc
turbo c++ online