![]() |
| ||
| Please help me understanding implementing this class I have an assignment to implement a salesperson class. Here is the layout I got from prof. My questions are typed in red between function prototypes. Any help is appreciated. Thanks.
|
| ||
| Re: Please help me understanding implementing this class These are basic questions that should be explained in your text, and in your lessons. In short, the default constructor will allocate the date member(s), sales[4] in this case, but will not initialize the array to any specific values. That would occur in a constructor that you create, such as the one you have with four doubles as parameters. "get" functions normally provide a means for accessing the class's private data, while "set" functions give you the means to modify the private data. |
| ||
| Re: Please help me understanding implementing this class Thanks, I actually figured out most of the stuff. But I have some problem in my code. In the main(), I am trying to print the sales figure, but instead it is printing the address of the sales array. How can I resolve this without using pointers. Once again, Thanks. My code
|
| ||
| Re: Please help me understanding implementing this class You need to keep things straight better. void Salesperson::setsales(int quart, double sales)Using the same name for your parameter as the data member array should be causing a compile error, as the one will mask the other. You should rename the parameter - say, "new_sales". Why are you adding all the quarterly sales values in this function? Your printsales( ) function is doing exactly what you tell it, displaying the address of the array. If you want to see each quarter's sales amount, you need to display each element of the array one at a time - best with a nice little for loop. If, on the other hand, you want to display just a total value, you still need that for loop to add up the array elements. Figure out what it is you really want to do. |
| All times are GMT -4. The time now is 2:30 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC