Thread: What is wrong with the following code?

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    34

    What is wrong with the following code?

    Thanks:

    Code:
    #include <iostream>
    #include <cstdlib>
    #include <string>
    using std::string;
    using namespace std;
    
    // SavingsAccount class definition
    class SavingsAccount
    {
    private:
       int accountType;
       string ownerName;
       long ssn;
       double accountClosurePenaltyPercent, accountBalance;
    
    public:
       void initializeMembers()
       {
          cout << "Please enter Account Type ( 1, 2, or 3 ): ";
          cin >> accountType;
          cout << "\nPlease enter owner's name: ";
          cin << ownerName;
          cout >> "\nPlease enter owner's SS number without dashes: ";
          cin << ssn;
          cout >> "\nPlease enter Accout Closure Penalty Percent: ";
          cin << accountClosurePenaltyPercent;
          cout >> "\nPlease enter Account Balance: ";
          cin << accountBalance;
       }
    };
    
    
    int main()
    {
       SavingsAccount MySavingsAccount;
    
       MySavingsAccount.initializeMembers();
    
       return(EXIT_SUCCESS);
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    What makes you think something is wrong with the code?

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    34

    Sorry...Here are the first few errors:

    1>c:\users\robert\my programs\assignment 8 exercise 1\source 1.cpp(32) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std:perator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
    1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(537) : see declaration of 'std:perator <<'
    1>c:\users\robert\my programs\assignment 8 exercise 1\source 1.cpp(32) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std:perator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
    1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(537) : see declaration of 'std:perator <<'
    1>c:\users\robert\my programs\assignment 8 exercise 1\source 1.cpp(32) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std:perator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
    1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(537) : see declaration of 'std:perator <<'
    1>c:\users\robert\my programs\assignment 8 exercise 1\source 1.cpp(32) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std:perator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
    1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string(537) : see declaration of 'std:perator <<'
    1>c:\users\robert\my programs\assignment 8 exercise 1\source 1.cpp(32) : error C2784: 'std::basic_ostream<char,_Traits> &std:perator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
    1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(930) : see declaration of 'std:perator <<'

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Several cin has the >> operator reversed (ie they are written as << when they should be >>).
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong in this simple code
    By vikingcarioca in forum C Programming
    Replies: 4
    Last Post: 04-23-2009, 07:10 AM
  2. what is wrong with this code please
    By korbitz in forum Windows Programming
    Replies: 3
    Last Post: 03-05-2004, 10:11 AM
  3. I cant find what is wrong with this code
    By senegene in forum C Programming
    Replies: 1
    Last Post: 11-12-2002, 06:32 PM
  4. Anyone see what is wrong with this code?
    By Wise1 in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 02:01 PM
  5. very simple code, please check to see whats wrong
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-10-2001, 12:51 AM