Skip to content

Instantly share code, notes, and snippets.

@tux21b
Created April 27, 2015 18:11
Show Gist options
  • Save tux21b/b1c06537a2f95853238f to your computer and use it in GitHub Desktop.
Save tux21b/b1c06537a2f95853238f to your computer and use it in GitHub Desktop.
#include <iostream>
#include <sstream>
class Rational
{
private:
int a;
int b;
public:
Rational(int a, int b) : a(a), b(b)
{
}
std::string toString()
{
std::ostringstream out;
out << a << "/" << b;
return out.str();
}
};
int main()
{
Rational num(1, 4);
std::cout << "my number: " << num.toString() << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment