Reputation: 25
I'm also receiving the 'no operator "<<" matches these operands" error while trying to display the information.
cout << (<- error with these) PrintHex(ASphere.CalcCircumference()) << endl;
I looked around and most people state that it's because of a missing #include. However I think I have everything I need to include. (it also doesn't become a problem until I try to display the info from the functions.)
#include <iostream>
#include <iomanip>
#include <string>
My function looks like this.
void PrintHex(int InNum)
{
cout << hex << setiosflags (ios_base::showbase) << InNum;
};
Upvotes: 0
Views: 210
Reputation: 477000
Just say:
PrintHex(ASphere.CalcCircumference());
Your function is not suitable to be used with <<
, since it doesn't return anything.
Upvotes: 2
Reputation: 21863
You are trying to print the output of a function that returns a void
, which means nothing.
Return something from your function if you want to print anything.
You can either:
PrintHex(ASphere.CalcCircumference());
and print from inside it (what you already do)stringstream
or a string
from your function and later print it with a cout
callUpvotes: 2
Reputation: 96810
PrintHex
already invokes std::cout
internally, so there's no reason to put it inside another std::cout
call.
PrintHex(ASphere.CalcCircumference());
That's all you need to do for it to print.
Upvotes: 3