У меня есть проект C++, над которым я работаю. Я немного в тупике. Мне нужна небольшая помощь. Мне нужно реализовать код из файла .h в файл main.cpp, и я не уверен, как это сделать.Как реализовать код в файле .h в файле main.cpp?
Например, код кода из 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;
}
и коды из .h файла:
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
В файле .h вам нужно будет использовать пустую вставку под трансформатором в main.cpp в случае 1. Как вы это сделаете? Любая помощь заслуживает внимания. Надеюсь, я никого не путал с тем, что мне нужно знать, как это сделать. Благодаря
включают .h файл в файл main.cpp и сделать реализацию. Если ваш .cpp не является загрузочным файлом (не имея основного), вам придется написать другой .cpp-файл, а затем ссылку на основную программу. – Jagannath
У меня есть файл .h, который находится в верхней части файла main.cpp. – Lea