Then maybe you need to either change your compiler warning levels or get a better compiler!
Jim
One thing is that yet i haven't declared any thing private in the Class but its still complaining about all member varaiables..
such as:
error C2248: 'account::name' : cannot access private member declared in class 'account'
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
But the compiler says,Code:Now it looks like this: class account { public: int acno; //account no. string name; //accountholder name int dep; //deposit char type; //C? or S? public: void create_account();//function to get data from user void show_account();//function to show data on screen void modify(); //function to get new data from user void deposit(int);//function to acceptt amount and add to balance amount void draw(int);//function to accept amount and subtract from balance amount void report();//function to show data in tabular format int ret_acno();//function to return account number int retdeposit();//function to return balance amount char rettype();//function to return type of account };
error LNK2019: unresolved external symbol "void __cdecl modify_account(int)" (?modify_account@@YAXH@Z) referenced in function _main
error LNK2019: unresolved external symbol "void __cdecl delete_account(int)" (?delete_account@@YAXH@Z) referenced in function _ma: error LNK2019: unresolved external symbol "void __cdecl display_all(void)" (?display_all@@YAXXZ) referenced in function _main
.obj : error LNK2019: unresolved external symbol "void __cdecl display_acc(int)" (?display_acc@@YAXH@Z) referenced in function _main
error LNK2019: unresolved external symbol "void __cdecl write_account(void)" (?write_account@@YAXXZ) referenced in function _main
1>c:\users\javed\documents\visual studio 2010\Projects\BMS comment_ver\Debug\BMS comment_ver.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
Aren't those function implementations in some of your comment out code?
The compiler is looking for global functions with those names, not class member functions.
Jim
>>error LNK2019: unresolved external symbol
Translation: you told me this function existed, but I couldn't find it!
>>"void __cdecl delete_account(int)" (?delete_account@@YAXH@Z)
OK, so this is the function I couldn't find. It's called delete_account and takes an int. It's in the global scope.
>>referenced in function _ma
This is the function where you apparently called the function I couldn't find.
Now here comes the Problem of cout while proceeding:
Infact for every line of code having cout is this curse happening!!!Code:class account { public: int acno; //account no. string name; //accountholder name int dep; //deposit char type; //C? or S? public: void create_account();//function to get data from user void show_account();//function to show data on screen void modify(); //function to get new data from user void deposit(int);//function to acceptt amount and add to balance amount void draw(int);//function to accept amount and subtract from balance amount void report();//function to show data in tabular format int ret_acno();//function to return account number int retdeposit();//function to return balance amount char rettype();//function to return type of account }; //class ends here istream& operator >> (istream& input, account& accs) { char tmp; input >>accs.acno>> tmp >> accs.name >> tmp >> accs.dep >> tmp >> accs.type; return input; // enables cin >> a >> b >> c; } ostream& operator << (ostream& output, const account& accs) { output<<accs.acno<<" "<<accs.name<<" "<<accs.dep<<" "<<accs.type<<"" "\n"; return output; } void account::create_account() { cout<<"\nEnter The account No."; cin>>acno; cout<<"\nEnter The Name of The account Holder :\n"; cin>>name; cout<<"Your name is :"<<name; cout<<"\nEnter Type of The account (C/S) : "; cin>>type; type=toupper(type); cout<<"\nEnter The Initial amount(>=500 for Saving and >=1000 for current ) : "; cin>> dep; while(type=='C' && dep<1000) { cout<<"Please enter amount >=1000"; cout<<"\n"; cin>>dep; } while(type=='S'&& dep<500) { cout<<"Please enter amount >=500"; cout<<"\n"; cin>>dep; } cout<<"\n\n\nAccount Created.."; cout<<"Good Luck :-)" ; } ........................................... int main() { char ch; int num; intro(); do { cout<<"\n\n\n\tMAIN MENU"; cout<<"\n\n\t1. NEW ACCOUNT"; cout<<"\n\n\t2. DEPOSIT AMOUNT"; cout<<"\n\n\t3. WITHDRAW AMOUNT"; cout<<"\n\n\t4. BALANCE ENQUIRY"; cout<<"\n\n\t5. ALL ACCOUNT HOLDER LIST"; cout<<"\n\n\t6. CLOSE AN ACCOUNT"; cout<<"\n\n\t7. MODIFY AN ACCOUNT"; cout<<"\n\n\t8. EXIT"; cout<<"\n\n\t Select Your Option (1-8) "; cin>>ch; switch(ch) { case '1': create_account(); break;
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
EVEN for a function intro():
Code:void intro() { cout<<"\n\n\n\n"; cout<<"\t\t***************************"; cout<<"\n\t\t BANK MANAGEMENT SYSTEM\n"; cout<<"\t\t***************************";// Error:error C2297: '<<' : illegal, right operand has type 'const char [30]' //warning C4552: '<<' : operator has no effect; expected operator with side-effect getch(); }
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
Separation of concerns. You should write the class to model an account. This class provides an interface by which client code can manipulate account objects. If there is I/O, then it would be at the more abstract level of working with std::istream and std::ostream.Originally Posted by jeedi khan
To actually provide features for the user, you write functions that make use of the class. These functions will then involve interactive I/O with the user, in this case the use of std::cin and std::cout, or sometimes interaction with a std::fstream. In another program, perhaps a GUI would be provided instead, but the same account class will still be usable because it was not tightly coupled with standard I/O.
I would refer back to post #48:Originally Posted by jeedi khan
I would get rid of the using directive (jimblumberg called it a using declaration, but those are slightly different) in the header file. Fully qualify the names from the std namespace that are used in the header file. The header file should have inclusion guards.Originally Posted by jimblumberg
Next, if you want the using directive in the source file, that's fine, but make sure it comes after the last header inclusion.
I would turn off the pre-compiled header feature and get rid of the inclusion of stdafx.h. This feature is useful for much larger projects, but here it tends to be more trouble than it is worth when you are still trying to figure out the basics of C++.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.