C++ | Stringstream | Clean code
Intuition:\nParse the numbers using stringstream and peform operation on 2 fractions at a time and keep storing the result in first one.\n\nSolution:\n\n\nclass
**Intuition:**\nParse the numbers using stringstream and peform operation on 2 fractions at a time and keep storing the result in first one.\n\n**Solution:**\n\n```\nclass Solution {\n    void addfraction(int &a, int &b, int c, int d) {\n        int nume = a*d + b*c;\n        int deno = b*d;\n        int gcd = __gcd(abs(nume), abs(deno));\n        a = nume/gcd; b = deno/gcd;\n    }\npublic:\n    string fractionAddition(string expression) {\n        \n        stringstream ss(expression);\n        char op;\n        int a, b, c, d;\n        \n        ss >> a; ss >> op; ss >> b;\n        while (ss >> c) {\n            ss >> op; ss >> d;\n            addfraction(a, b, c, d);\n        }\n        \n        string res;\n        res = to_string(a) + "/" + to_string(b);\n        return res;\n    }\n};\n```
[]