| BasicNewbie (145) | |||
Here the work i done so far
And here is the question given Create a class template for a class that holds an object and the number of data elements in the object. For example, if an Employee class has two data elements, an ID number and a salary, then the class template holds the number 2 and an Employee object; if a Student class contains 12 data elements, then the class template holds 12 and a Student object. Write the code for standard input function for the object that displays a message on the screen – “You will be ask to enter X items” – where X is the number of data elements. Write a main() function that tests your template class with an integer and two programmer-defined classes So can i ask that , am i do correctly so far? what is the mistake i made ? | |||
|
|
|||
| codewalker (159) | |
constructors dont return anything, when declaring variable of a template class you need to pass the type to it Employee <> theEmployee( 2 , 3000 ); should look something like Employee <int> theEmployee( 2 , 3000 ); | |
|
|
|
| closed account (DETpfSEw) | |
|
Number 1: you should remove return type from constructor of first class. because constructor returns nothing. Number 2: specify data type in main function when instantiating the template based classes. ENJOY!!! | |
|
|
|
| BasicNewbie (145) | |
|
Did i fullfill what question want me to do? err . remove return type ? did u mean create accessor or mutator? | |
|
|
|
| Gulshan Singh (46) | |||||
He means this
Should be this
| |||||
|
|
|||||
| BasicNewbie (145) | |
|
okay. i changed it . i get what he mean . but now if a Student class contains 12 data elements, then the class template holds 12 and a Student object. Write the code for standard input function for the object that displays a message on the screen – “You will be ask to enter X items” – what mean for this sentences? how should the class Student pass the parameter to constructor? abit blur with it | |
|
|
|
| BasicNewbie (145) | |
| mind to help for me template? | |
|
|
|
| BasicNewbie (145) | |||
the work i done so far . so any advise? | |||
|
|
|||
| Gulshan Singh (46) | |
|
You have a basic misunderstanding of templates. Please read and understand this: http://www.cplusplus.com/doc/tutorial/templates/ You seem to also have an issue with passing parameters to the constructor, so read this: http://www.cplusplus.com/doc/tutorial/classes/ After reading those and changing your code based on what you learned, then post back and show us what you've done. | |
|
|
|
| BasicNewbie (145) | |||
the work i done so far. last code is incomplete . just get some concept. hmm. i read slide from my class and base on that to do some changes on it | |||
|
|
|||
| BasicNewbie (145) | |
| mind a senior teach me ? | |
|
|
|