Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Homework HelpRSS Feeds

Program that provides an example of This pointer

Posted By: Bathilda Schmidt     Category: C++ Programming     Views: 12079

Write a program that provides an example of This pointer.

Code for Program that provides an example of This pointer in C++ Programming

#include<iostream.h>
#include<conio.h>
class max
{
    int a;
    public:
        void getdata()
        {
            cout<<"Enter the Value :";
            cin>>a;
        }
        max &greater(max &x)
        {
            if(x.a>=a)
                return x;
            elsereturn *this;
        }
        void display()
        {
            cout<<"Maximum No. is : "<<a<<endl;
        }
};
main()
{
    clrscr();
    max one,two,three;
    one.getdata();
    two.getdata();
    three=one.greater(two);
    three.display();
    getch();
}
  
Share: 


Didn't find what you were looking for? Find more on Program that provides an example of This pointer Or get search suggestion and latest updates.

Bathilda Schmidt
Bathilda Schmidt author of Program that provides an example of This pointer is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!