In my cdrom class I have a member function called returncost, and a private data member cost.

float cdrom::returncost()

Later, in a free function I call that member function to calculate a total cost and average cost.

void showcosts (cdrom &cd1, cdrom &cd2, cdrom &cd3)
     cout << "the total cost of the CD's is:" <<      (cd1.returncost+cd2.returncost+cd3.returncost)<<endl:

     cout << "the average cost of the CD's is:" <<     (cd1.returncost+cd2.returncost+cd3.returncost)/3      <<endl:

It tells me
cdrom::returncost function call missing argument list/ use &cdrom::returncost to create a pointer to member
followed by another error from the same line:
+ illegal left operand has type float (this call cdrom:: *) (void)

Now I know I've done something wrong, but I'm at a loss as to how to fix it, what am I missing that I should know already?

8 Years
Discussion Span
Last Post by henpecked1

Now see, I new it was something dumb like that and I was just missing it. Okay, next one...in main, I call a free function called displaycds.

The code for displaycds looks like so:

void displaycds (cdrom *cd1, cdrom *cd2, cdrom *cd3)

displayinfo is a member function of my cdrom class coded as so:

void cdrom::displayinfo()
     cout << name << cdtype << cost << endl;

name, cdtype and cost are all datamembers filled by user input. Now I know I've done something dumb here too, I've just been working at this so long I'm brain dead enough that I can't see it. I think my displayinfo is wrong but I"m not sure how.


displayinfo will display the name, type, and cost of a cd object after the information is loaded (another member function called loadinfo is called first)

displaycds is supposed to display 3 of them


Well the function is correct, if it doesn't work you should make sure the data is filled in correctly.


Okay, I figured that one out, I wasn't giving it any parameters when I called it in main...now I just have to figure out what kind of parameters show costs takes (similar makeup) and then figure out how to use the destructors and it might actually work :)

Thanks for the help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.