by Dinesh Thakur Category: Classes in C++

 

#include<iostream.h>

#include<conio.h>
class flight
{
        private:
                      char flight_name[15];
                      int flight_no;
                      char source[15];
                      char destination[15];
       public:
                      void readdata()
                  {
                           cout<< "Flight Name : ";
                           cin >>flight_name;
                           cout<< "Flight Number : ";
                           cin >>flight_no;
                           cout<< "Source : ";
                           cin >>source;
                           cout<< "Destination : ";
                           cin >>destination;
                   }
                       void writedata()
                  {
                        cout<< "Flight Name : "<<flight_name<<endl;
                        cout<< "Flight Number : "<<flight_no<<endl;
                        cout<< "Source : "<<source<<endl;
                        cout<< "Destination : "<<destination<<endl;
                   }
};
             void main()
        {
             clrscr();
             flight flight_domestic[10];
             int n,i;
             cout<<"Enter the Total Number of Flight "<<endl;
             cin >> n;
             for(i=0;i<n;i++)
                 {
                    cout<< "Enter Data for Flight : "<<i+1<<endl;
                    flight_domestic[i].readdata();
                   
                 }
                    cout << "Flight Data Details "<<endl;
                    for(i=0;i<n;i++)
                        {
                            flight_domestic[i].writedata();
                            getch();
                        }
       }

Array of Object

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article