Pradyut 的个人资料Object Oriented Programm...照片日志列表更多 工具 帮助
5月5日

c++ program to show the sequence of output from derived class

 

 

//Show the sequence of output from derived class

 

#include <iostream>

#include <conio.h>

 

using namespace std;

 

class Abc

{

public:

            Abc()

            {

                        cout<<"This is inside ABC" <<endl;

            }

            void show()

            {

                        cout <<"This is the show method" <<endl;

            }

};

 

class New : public Abc

{

public:

            New()

            {

                        cout <<"This is inside New" <<endl;

            }

};

 

int _tmain(int argc, _TCHAR* argv[])

{

            cout <<"testing" <<endl;

            New obj;

            obj.show();

            getch();

            return 0;

}

 

/*

OUTPUT:

            testing

            This is inside ABC

            This is inside New

            This is the show method

*/

 

 

 

 

--
Pradyut
http://pradyut.tk
http://oop-edge.blogspot.com/
http://pradyutb.blogspot.com/
http://praddy-photos.blogspot.com/
http://oop-edge.spaces.live.com/
http://www.flickr.com/photos/praddy
http://groups.google.com/group/oop_programming
India

 

5月2日

C++ program to show constructor to initialize base class

 

 

//shows constructor to initialize base class

 

#include <iostream.h>

 

class Nine

{

     public:

            int x, y;

            Nine(int a, int b)

            {

                        x=a;

                        y=b;

            }

            void showdata()

            {

                        cout <<"The values are: " <<x <<" and " <<y;

            }

};

 

class Ten: public Nine

{

            int l,m;

     public:

 

            Ten(int w, int d) : Nine(w,d)

            {

                        l=w;

                        m=d;

            }

            void showdata()

            {

                        cout <<"The values are: " <<l <<" , " <<m <<" , " <<x <<" , " <<y;

            }

};

 

int main()

{

            //Nine obj1(3,4);

            Ten obj2(5,6);

            //obj1.showdata();

            obj2.showdata();

            return 0;

}

 

 

 

 

--
Pradyut
http://pradyut.tk
http://oop-edge.blogspot.com/
http://pradyutb.blogspot.com/
http://praddy-photos.blogspot.com/
http://oop-edge.spaces.live.com/
http://www.flickr.com/photos/praddy
http://groups.google.com/group/oop_programming
India

 

c++ program to show difference in base class values

 

 

//shows difference in base class values

 

#include <iostream.h>

 

class High

{

      public:

      int d, m;

     

      void getdata(int a, int b)

      {

            d=a;

            m=b;

      }

      void showdata()

      {

            cout <<"The values are: " <<d <<" , " <<m <<endl;

      }

     

};

 

class Low: public High

{

      int g,l;

      public:

      void getdata(int a, int b)

      {

            g=a;

            l=b;

           

      }

      void showdata()

      {

            //trash values for base class members d and m

            cout <<"The values are: " <<g <<" , " <<l << " , " <<d <<" , " <<m <<endl;

            d=g;

            m=l;

      }

     

      void showdata1()

      {

            //values for d and m after showdata initialization

            cout <<"The values are: " <<g <<" , " <<l << " , " <<d <<" , " <<m;

      }

};

 

 

int main()

{

      High obj1;

      obj1.getdata(4,5);

      Low obj2;

      obj2.getdata(5,6);

      obj1.showdata();

      obj2.showdata();

      obj2.showdata1();

      return 0;

}

 

 

 

--
Pradyut
http://pradyut.tk
http://oop-edge.blogspot.com/
http://pradyutb.blogspot.com/
http://praddy-photos.blogspot.com/
http://oop-edge.spaces.live.com/
http://www.flickr.com/photos/praddy
http://groups.google.com/group/oop_programming
India

 

c++ program to show parameterized constructor

//shows parameterized constructor
#include <iostream.h>

class Gear
{
int x, y;
public:
Gear(int a, int b)
{
x = a;
y = b;
}

void showdata()
{
cout <<"The values are: " <<x <<" and " <<y;
}
};

int main(void)
{
Gear obj(3,4);
obj.showdata();
return 0;
}

--
Pradyut
http://pradyut.tk
http://oop-edge.blogspot.com/
http://pradyutb.blogspot.com/
http://praddy-photos.blogspot.com/
http://oop-edge.spaces.live.com/
http://www.flickr.com/photos/praddy
http://groups.google.com/group/oop_programming
India
5月1日

mohabbat shayari

Main saahil pey likhee hoee ibaarat nahee
Jo lehron se mit jaati hay
Main baarish ki barasti boond nahee
Jo baras ker tham jaati hay
Main khwab nahee
Jisey dekha aur bhula dya
Main shama nahee
Jisey phoonka aur bujha dya
Main hawa ka jhonka nahee
Jo aaya aur guzar gaya
Main chand bhi nahee
Jo raat k baad dhal jaye
Main to woh ahsaas hoon
Jo tujh main lahoo ban ker gardish karay
Main to woh rang hoon
Jo teray dil pay charay to kabhi na mitay
Main woh geet hoon
Jo teray labon se juda na hoga
Main to woh parwaana hoon
Jo jalta rahayga magar fana na hoga
Khwab,ibaarat,hawa ki tarah
Chand,boond,shama ki tarah
Meray mitnay ka sawaal nahee
Kyunkay MÄÏN TÖ MÖHÄßßÄT HÖÖN

Aur Mohabbat Koi Zawaal Nahee....!!


--
Pradyut
http://pradyut.tk
http://oop-edge.blogspot.com/
http://pradyutb.blogspot.com/
http://praddy-photos.blogspot.com/
http://oop-edge.spaces.live.com/
http://www.flickr.com/photos/praddy
http://groups.google.com/group/oop_programming
India