我有一个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