Final answer:
A Train class in C++ with data members for train details and member functions for initializing and displaying train data can be encapsulated in a simple program. Implementation includes member functions InitializeMembers, InputTrainData, and DisplayData.
Step-by-step explanation:
The requested Train class in C++ can be defined with the following members. The Data Members will include train number, train name, destination, journey date, and capacity. The Member Functions will handle the initialization, input, and display of train data. Below is a simple C++ program that demonstrates the implementation of such a class.
class Train {
public:
int trainNumber;
string trainName;
string destination;
string journeyDate;
int capacity;
void InitializeMembers(int number, string name, string dest, string date, int cap) {
trainNumber = number;
trainName = name;
destination = dest;
journeyDate = date;
capacity = cap;
}
void InputTrainData() {
// Code to input train data
}
void DisplayData() {
cout << "Train Number: " << trainNumber << endl;
cout << "Train Name: " << trainName << endl;
cout << "Destination: " << destination << endl;
cout << "Journey Date: " << journeyDate << endl;
cout << "Capacity: " << capacity << endl;
}
};
int main() {
Train myTrain;
myTrain.InitializeMembers(101, "Express", "Gotham", "2023-04-18", 300);
myTrain.DisplayData();
return 0;
}