Thread: Exception issue

  1. #76
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Quote Originally Posted by jimblumberg View Post
    See the edited post #71, that code doesn't compile for many reasons, but not what you're describing.
    Suggestion Noted for "comments";;;
    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.

  2. #77
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Then maybe you need to either change your compiler warning levels or get a better compiler!

    Jim

  3. #78
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    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.

  4. #79
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Quote Originally Posted by jimblumberg View Post
    Then maybe you need to either change your compiler warning levels or get a better compiler!

    Jim
    I would really like to know about it...Which compiler should i go for ?
    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.

  5. #80
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Quote Originally Posted by jimblumberg View Post
    See the edited post #71, that code doesn't compile for many reasons, but not what you're describing.
    YES,after a little editing it is also not giving now cout error with me
    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.

  6. #81
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by jeedi khan View Post
    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'
    Well, you declared them as private!
    Everything, unless put under a public label, is by default private in classes.

    Quote Originally Posted by jeedi khan View Post
    I would really like to know about it...Which compiler should i go for ?
    Your current compiler is fine, but outdated. You should upgrade to 2013.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #82
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Quote Originally Posted by Elysia View Post
    Well, you declared them as private!
    Everything, unless put under a public label, is by default private in classes.
    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
    };
    But the compiler says,
    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.

  8. #83
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    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

  9. #84
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    >>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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #85
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Now here comes the Problem of cout while proceeding:
    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;
    Infact for every line of code having cout is this curse happening!!!
    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.

  11. #86
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    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.

  12. #87
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jeedi khan
    Quote Originally Posted by laserlight
    create_account should not be a member function. Rather, it should be a non-member non-friend function that makes use of the interface provided by the account class to do interactive I/O.
    Why so dear?
    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.

    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.

    Quote Originally Posted by jeedi khan
    Infact for every line of code having cout is this curse happening!!!
    I would refer back to post #48:
    Quote Originally Posted by jimblumberg
    There are a couple of minor issues I see with your class include file. First you have way too many include files, and then you tromp on everything by using the using declaration. This file appears to only need three header files at most, <stdafx.h>, <string>, and <vector>. You should use the scope resolution operator:: to properly scope the classes from the std namespace instead of the "using" statement. And I would really prefer that stdafx.h were not used, perhaps something happened to corrupt this header.
    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.

    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++.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  13. #88
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by jeedi khan View Post
    Now here comes the Problem of cout while proceeding:

    Infact for every line of code having cout is this curse happening!!!
    And now we're back to the beginning again...
    Whee, the world sure is round!
    HINT: Re-read the replies advising you what to do when you first reported this problem.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #89
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Quote Originally Posted by Elysia View Post
    And now we're back to the beginning again...
    Whee, the world sure is round!
    HINT: Re-read the replies advising you what to do when you first reported this problem.
    Thats new to me :
    OK, to get rid of so many header files and including at most <string> <vector> <stdafx> then will you let me know how to avoid using namespace std i.e should i go for std::cin/std::cout everywhere and what more?
    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.

  15. #90
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Quote Originally Posted by jeedi khan View Post
    Thats new to me :
    OK, to get rid of so many header files and including at most <string> <vector> <stdafx> then will you let me know how to avoid using namespace std i.e should i go for std::cin/std::cout everywhere and what more?
    Also std::setw is also not working and
    Code:
     std::ifstream inFile; // incomplete type is not allowed
       std:: ofstream outFile;// incomplete type is not allowed
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Exception errors OR exception handling :S
    By cruiser in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2011, 05:30 AM
  2. bandwidth issue / network issue with wireless device communication
    By vlrk in forum Networking/Device Communication
    Replies: 0
    Last Post: 07-05-2010, 11:52 PM
  3. Handle C++ exception and structured exception together
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 01-24-2008, 09:21 PM
  4. R/W to 0x0 exception how to????
    By symptom in forum C Programming
    Replies: 2
    Last Post: 06-07-2005, 10:59 AM
  5. An "throwing exception" issue
    By viniciusMarques in forum Windows Programming
    Replies: 3
    Last Post: 06-02-2004, 10:38 AM