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

float cdrom::returncost()
{
     return(cost)
}

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?

You're not calling it. To call a function, use, for example, cd3.returncosts()

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)
{
     cd1->displayinfo();
     cd2->displayinfo();
     cd3->displayinfo();
}

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.

What exactly is it doing & what is the expected output?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.