Ich habe ein C++ Projekt, an dem ich arbeite. Ich bin im Moment ein wenig ratlos. Ich brauche ein wenig Hilfe. Ich muss Code aus der .h-Datei in die main.cpp-Datei implementieren und bin mir nicht sicher, wie das geht.Wie würde ich Code in einer .h-Datei in die main.cpp-Datei implementieren?
Zum Beispiel Code Code aus main.cpp:
switch (choice){
case 1: // open an account
{
cout << "Please enter the opening balence: $ ";
cin >> openBal;
cout << endl;
cout << "Please enter the account number: ";
cin >> accountNum;
cout << endl;
break;
}
case 2:// check an account
{
cout << "Please enter the account number: ";
cin >> accountNum;
cout << endl;
break;
}
und Code aus der h-Datei:
void display(ostream& out) const;
// displays every item in this list through out
bool retrieve(elemType& item) const;
// retrieves item from this list
// returns true if item is present in this list and
// element in this list is copied to item
// false otherwise
// transformers
void insert(const elemType& item);
// inserts item into this list
// preconditions: list is not full and
// item not present in this list
// postcondition: item is in this list
In der H-Datei müssen Sie den Leereinsatz unter Transformator verwenden, in der main.cpp in Fall 1. Wie würden Sie das tun? Jede Hilfe ist erwünscht. Ich hoffe, ich habe niemanden verwirrt, was ich tun muss. Dank
die .h-Datei in Ihrer main.cpp-Datei enthalten und macht die Implementierung. Wenn Ihre .cpp nicht die Startup-Datei ist (ohne main), müssen Sie eine weitere .cpp-Datei schreiben und dann eine Verknüpfung zum Hauptprogramm herstellen. – Jagannath
Ich habe die .h-Datei am Anfang der main.cpp-Datei enthalten – Lea