-
October 21st, 2012, 07:03 AM
#1
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;
}
-
October 22nd, 2012, 05:00 PM
#2
Re: c++ employee class
Originally Posted by baby2012
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;
}
- Please, use Code tags! Neither HTML, nor PHP.
- Please, use proper indentations within the code.
- Please, don't avoid braces.
- What are the error messages you get?
- main() function must be int, not void.
Victor Nijegorodov
-
October 23rd, 2012, 05:04 AM
#3
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
-
October 23rd, 2012, 08:55 AM
#4
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.
-
October 23rd, 2012, 12:22 PM
#5
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
-
October 23rd, 2012, 12:26 PM
#6
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.
-
October 23rd, 2012, 12:32 PM
#7
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
-
October 23rd, 2012, 12:44 PM
#8
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
-
October 23rd, 2012, 04:00 PM
#9
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....
-
October 23rd, 2012, 04:31 PM
#10
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
-
October 24th, 2012, 02:36 AM
#11
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
-
October 24th, 2012, 07:18 AM
#12
Re: c++ employee class
Originally Posted by baby2012
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|