How would I implement code in a .h file into the main.cpp file?
Posted
by
Lea
on Stack Overflow
See other posts from Stack Overflow
or by Lea
Published on 2012-03-26T23:25:45Z
Indexed on
2012/03/26
23:29 UTC
Read the original article
Hit count: 184
c++
I have a c++ project I am working on. I am a little stumped at the moment. I need a little help. I need to implement code from the .h file into the main.cpp file and I am not sure how to do that.
For example code code from 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;
}
and code from the .h file:
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 the .h file you would need to use the void insert under transformer in the main.cpp under case 1. How would you do that? Any help is apprecaited. I hope I didn't confuse anyone on what I am needing to know how to do. Thanks
© Stack Overflow or respective owner