Thread: errors

  1. #1
    Registered User sentienttoaster's Avatar
    Join Date
    Nov 2002
    Posts
    79

    errors

    I am going to paste my code. It for what is there, I thin kit should run, but I am getting some wierd errors that I cannot fix. Take a look and see if you can see what is wrong.

    Code:
    #include<iostream>
    #include<fstream>
    #include<string>
    using namespace std;
    
    
    class employee
    {
    public:
      string lname;
      string fname;
      string address;
      string city;
      string state;
      string zip;
      char hos;
      int payrate;
      int hours;
      int dependents;
      int gpay;
      int fed;
      int state1;
      int social;
      int net;
      int compute(int payrate, int hours, int dependents, int gpay, int fed, int state1, int social, int net, char hos);
      
    
    
    };
    
    
    int main()
    {
      string in;
      string out;
      cout<<"Enter the name of the file you want to write to.";
      cin>>out;
      cout<<"Enter the name of the file you want to read from.";
      cin>>in;
      ifstream instream;
      instream.open(in, ios::in);
      ofstream outstream;
      outstream.open(string out);
     employee::compute(int payrate, int hours, int dependents, int gpay, int fed, int state1, int social, int net, char hos);
      
    
    
    
      instream.close();
      ofstream.close();
      return 0;
    }
    
    int compute(int payrate, int hours, int dependents, int gpay, int fed, int state1, int social, int net, char hos)
    {
      if(hos=='h'||'H')gpay=hours*payrate*100;
      if(hos=='s'||'S')gpay=payrate/26*100;
      fed=(gpay*26)-(2500*dependents)*(.28/.26)*100;
      state1=gpay*.048*100;
      social=gpay*.075*100;
      return (gpay, fed, state1, social);
    }
    This has been a public service announcement from GOD.

    111 1111

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    errors would be helpful...

    this is what it should be:
    Code:
    #include<iostream>
    #include<fstream>
    #include<string>
    using namespace std;
    
    
    class employee
    {
    private:  //what's the point of classes w/o private members
      string lname;
      string fname;
      string address;
      string city;
      string state;
      string zip;
      char hos;
      int payrate;
      int hours;
      int dependents;
      int gpay;
      int fed;
      int state1;
      int social;
      int net;
    public:
      [color=red]bool[/bool] compute(char*,char*);  //all the ints are already accessable by this function - it's a class
    };
    
    
    int main()
    {
      string in;
      string out;
    
      employee employeeclass;  //need to create an instance of the class, kinda like ifstream/ofstream
    
      cout<<"Enter the name of the file you want to write to.";
      cin>>out;
      cout<<"Enter the name of the file you want to read from.";
      cin>>in;
    
      employeeclass::compute(in,out);  [color=blue]//the ofstream & ifstream need to be in the function, not out here
    
      /* enter output functions here */
    
      return 0;
    }
    
    bool compute(char*in,char*out)
    {
      ifstream instream(in);  [color=blue]//four lines of code down to two ;)
      ofstream outstream(out);
    
      if(hos=='h'||'H')gpay=hours*payrate*100;
      if(hos=='s'||'S')gpay=payrate/26*100;
      fed=(gpay*26)-(2500*dependents)*(.28/.26)*100;
      state1=gpay*.048*100;
      social=gpay*.075*100;
    
      ifstream.close();
      ofstream.close();
    
      return true;  //not necessary to return anything
    }
    Last edited by major_small; 11-17-2003 at 09:01 AM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 02:57 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM