c++ employee class
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: c++ employee class

  1. #1
    Join Date
    Oct 2012
    Posts
    4

    c++ employee class

    i would appreciate if someone can check out for me why l can't build this code, l have tried everything possible, have been on it for 2wks though lm new in c++ class. can not even say this is the error as it is giving me 45 errors. l am writing code which accept employee type based on calculating the miles travelled in a year,my code is based on type of employee, number of vacation days used and no of sick days used.

    #include <iostream>
    #include <iomanip>
    #include <conio.h>

    class employee {
    int emp_type;
    float emp_vacation;
    public
    void assign; (int e, float ec);{ empl_type; empl_vacations }=e;
    void disp () const { cout <<endl<< setw(20)<<empl_type<< setw(15)<<empl_vacation;}


    };
    void main (void)
    cout << employeetype ;<<;
    cout<<vacationdaysused ;<<;
    cout <<sickdaysused ;<<;
    employee x [2]; int a; float b;

    for(int i=0; i<2
    cout<< Enter employee"<<++i<<" type;" cin>>a; << \n"
    cout << Enter employee "<<i<<" vacationdaysused;" cin>>b;<< \n"
    cout << Enter employee "<<i<<"sickdaysused;"<<; \n"
    x[i+1]. assign (a,b);
    cout <<setw (1) << "employeevacationdaysused"<<setw(2)<<" employeesickdaysused;"
    for (int j)=0; j<2>; j++) { x [j].disp ();


    return 0;

    }

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,423

    Re: c++ employee class

    Quote Originally Posted by baby2012 View Post
    i would appreciate if someone can check out for me why l can't build this code, l have tried everything possible, have been on it for 2wks though lm new in c++ class. can not even say this is the error as it is giving me 45 errors. l am writing code which accept employee type based on calculating the miles travelled in a year,my code is based on type of employee, number of vacation days used and no of sick days used.

    Code:
    #include <iostream>
    #include <iomanip>
    #include <conio.h>
    
    class employee {
    	int emp_type;
    		float emp_vacation;
    public
    	void assign; (int e, float ec);{ empl_type; empl_vacations }=e;
    	void disp () const { cout <<endl<< setw(20)<<empl_type<< setw(15)<<empl_vacation;}
    	
    
    };
      void main (void)
    	  cout << employeetype ;<<;
          cout<<vacationdaysused ;<<;
    	  cout <<sickdaysused ;<<;
      employee x [2]; int a; float b;
    
    	  for(int i=0; i<2;)
    		  cout<< Enter employee"<<++i<<" type;" cin>>a; << \n"
    		  cout << Enter employee "<<i<<" vacationdaysused;" cin>>b;<< \n"
    		  cout << Enter employee "<<i<<"sickdaysused;"<<; \n"
    		  x[i+1]. assign (a,b);
    		  cout <<setw (1) << "employeevacationdaysused"<<setw(2)<<" employeesickdaysused;"
    			  for (int j)=0; j<2>; j++) { x [j].disp ();
    			  
    	    
    		return 0;
    
    }
    1. Please, use Code tags! Neither HTML, nor PHP.
    2. Please, use proper indentations within the code.
    3. Please, don't avoid braces.
    4. What are the error messages you get?
    5. main() function must be int, not void.
    Victor Nijegorodov

  3. #3
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,242

    Re: c++ employee class

    You like using semicolons don't you... even in places where they're not needed..!

    What's this supposed to mean

    Code:
    void assign; (int e, float ec);{ empl_type; empl_vacations }=e;
    Your quotation marks look suspiciously like they're in the wrong places too...

    Code:
    cout << Enter employee "<<i<<" vacationdaysused;" cin>>b;<< \n"
    Did you mean:-

    Code:
    cout << "Enter employee " << i << " vacation days used" << endl;
    cin >> b;
    Don't take this the wrong way but if this is course work, the best way to learn is to pay attention during the lessons People here can help you with specific problems but if you don't understand what your lecturer wants from you, nobody here can read his mind.

    Good luck with your studies..!
    Last edited by John E; October 23rd, 2012 at 08:59 AM.
    "A problem well stated is a problem half solved. - Charles F. Kettering

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,108

    Re: c++ employee class

    I'm having trouble even following your thinking here as your syntax is pretty far off in a lot of places. How are you going about learning?

    This for example
    void assign; (int e, float ec);{ empl_type; empl_vacations }=e;
    isn't even close and really makes no sense.

    Get yourself a good basic book and work through it. You appear to be guessing, and that will never work.

  5. #5
    Join Date
    Oct 2012
    Posts
    4

    Re: c++ employee class

    i am sorry l disturbed you guys on this forum, only one person did not post insult on the question i asked. l am new on this course and l am taking it online for job reason, why all this insults directed.
    l am sorry for posting

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,108

    Re: c++ employee class

    Nobody's insulting you and we're happy to help you. This is kind of a tough love forum though. Are you taking an actual, formal course or just looking at Youtube videos or websites? The problem is you're missing some very, very basic fundamentals which makes me ask where you're learning from. At a minimum you need to figure out how to use the semi-colon and curly braces. Most of your problems come from their incorrect use.

  7. #7
    Join Date
    Oct 2012
    Posts
    4

    Re: c++ employee class

    thanks for responding. i am taking an online course due to challenges l have and l simply came here as l have no alternative, and l really want to know it as l can't seems to find help anywhere even my prf is not helping me. saying l should go out reason l was refered here by a friend

  8. #8
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,242

    Re: c++ employee class

    Once you've been here a few times you'll realise that the insults are light-hearted. Nobody wants to demoralize you - but....

    please understand that this site is for helping programmers with programming problems. Beginners are very welcome but the site isn't here to teach you the basics of a programming language. You need to understand the basic principles (already). Otherwise, how can you understand the answers you get? (and how can other people understand your questions?)

    A good place for beginners to start is by buying a "Teach Yourself" book. There are bound to be examples in the book that you don't understand - so come here with your questions and people will help you understand them.
    Last edited by John E; October 23rd, 2012 at 12:55 PM.
    "A problem well stated is a problem half solved. - Charles F. Kettering

  9. #9
    Join Date
    Oct 2012
    Posts
    17

    Re: c++ employee class

    One thing I can say in respect to insults is that, I too have asked for help , on forums or on chat rooms, and the Responses are pretty
    blunt, and direct, but I've come to understand after many exchanges, that indeed they are not insults nor are the responses intended
    to be condescending.
    Point is, try not to misinterpret direct and blunt answers as offensive, the fact that they are taking the time to respond means
    that they want to help...which is good....
    ..Well ,,,those are my two cents on the matter...
    Live Long and Prosper....

  10. #10
    Join Date
    Oct 2012
    Posts
    4

    Re: c++ employee class

    thanks l appreciate it and lm grateful. it just that it saddens when you asked for help and you are been condemned.
    i understand and once again thank you

  11. #11
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,242

    Re: c++ employee class

    Anyway - you got a few good suggestions to check that your semicolons, curly braces and quotation marks are in the right place (and only use them where they're needed). After you apply those changes your code should look a lot different from how it looked in the first place. Post a revised version if it's still not working. Your code should be much easier to understand now, if you applied those changes.
    "A problem well stated is a problem half solved. - Charles F. Kettering

  12. #12
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,108

    Re: c++ employee class

    Quote Originally Posted by baby2012 View Post
    thanks l appreciate it and lm grateful. it just that it saddens when you asked for help and you are been condemned.
    i understand and once again thank you
    "comdemned"??? Now you're being a little melodramatic. John E correctly explained the situation. A minimal knowledge is required to be able to take advantage of this forum, and you're not there yet. Nobody is condemning you, and I imagine everybody wishes you well and hopes you stick around. But you have to have a minimal foundation before anybody can help you. There's so much wrong with your code, that even if we corrected it for you, it's not likely it would mean anything to you. Get a book. Work through the basics, then when you know how to properly format a statement, come on back.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center