string Fraction

Hi peeps, mind helping me out with this code? I won't paste all the code but if need be I will post it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
void Fraction::printFraction()
{
//So, I'm supposed to use this info for my function getFraction();
cout << this->num << "/" << this->den << endl;
}

string Fraction::getFraction()
{ //My code in this function is most likely wrong
//The issue here is I don't know how to properly code this function
//using this->num << "/" << this->den
string getS;
cout << this->num << "/" << this->den << endl;
return getS
}
1
2
3
4
string Fraction::getFraction()
{ 
  return (std::to_string(num) + '/' + std::to_string(den));
}
Last edited on
My project if working fine now. Thanks, Repeater!
Topic archived. No new replies allowed.