#include <iostream>using namespace std;class Train { private: int number, cap; string destination, name, date; public: Train(){}Train(int nu, int c, string d, string n, string da){ number =nu; cap = c; destination = d; name = n; date = da; }int trainNumber(){ cout<<"Enter train number\n"; cin>> number; return number;}int trainCapacity(){ cout<<"Enter train capacity\n"; cin>> cap; return cap; }string trainDestination(){ cout<<"Enter train destination\n"; cin>>destination; return destination;}string trainName(){cout<<"Enter train name\n";cin>>name;return name; }string trainDate(){ cout<<"The journey date\n "; cin>> date; return date; } void display(){ cout<<"Train number\t"<<trainNumber()<<endl; cout<<"Train capacity\t"<<trainCapacity()<<endl; cout<<"Train Destination\t"<<trainDestination()<<endl; cout<<"Train name\t"<<trainName()<<endl; cout << "Train journey date\t" << train destination<<endl; }};int main(){Train t;string name = t.trainName();string Destination = t.trainDestination();string date = t.trainDate();int number = t.trainNumber();int cap = t.trainCapacity(); Train t1(number,cap, Destination, name,date);t1.display(); return 0;}
Comments
Leave a comment