Created
April 27, 2015 18:11
-
-
Save tux21b/b1c06537a2f95853238f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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