我有一個C++項目,我正在研究。我現在有點難過。我需要一點幫助。我需要將.h文件中的代碼實現到main.cpp文件中,我不知道該怎麼做。如何將.h文件中的代碼實現到main.cpp文件中?
對於來自main.cpp中的代碼示例代碼:從.h文件
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;
}
和代碼:
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文件,你需要使用的空白插入變壓器下在案例1中的main.cpp中。你會怎麼做?任何幫助apprecaited。我希望我不會把任何人都弄糊塗,因爲我需要知道如何去做。由於
包括在您的main.cpp文件.h文件並執行實施。如果您的.cpp文件不是啓動文件(不是主文件),那麼您必須編寫另一個.cpp文件,然後鏈接到主程序。 – Jagannath 2012-03-26 23:28:20
我的.h文件包含在main.cpp文件的頂部 – Lea 2012-03-26 23:32:25