A Fraction class in C++ I am trying to learn clear and concise C++. Currently I'm learning classes in school, and to practice I have made a Fraction class.

I'd appreciate any help regarding style, cleanliness or anything else that would be good to know.

(I know using namespace std; is frowned upon, but it's required in our course.)

#include &lt;iostream&gt;
using namespace std;

class Fraction {
    int numerator, denominator;
private:
    int gcd(int a, int b) {
        while (a != b) {
            if (a &gt; b)
                a -= b;
            else
                b -= a;
        }
        return a;
    }
public:
    Fraction (int, int);
    double decimal();
    string fraction();
    Fraction add(Fraction);
    Fraction subtract(Fraction);
    Fraction multiply(Fraction);
    Fraction divide(Fraction);
};

int main() {
    Fraction f = {2,3};
    cout &lt;&lt; f.decimal() &lt;&lt; endl;
    Fraction k = {1,4};
    Fraction d = {1,3};
    Fraction result = k.add(d).add(f);
    cout &lt;&lt; result.fraction() &lt;&lt; endl;
    return 0;
}

Fraction::Fraction(int n, int d) {
    numerator = n / gcd(n, d);
    denominator = d / gcd(n, d);

}
string Fraction::fraction() {
    return to_string(numerator) + "/" + to_string(denominator);
}
double Fraction::decimal() {
    return (double)numerator / (double)denominator;
}

Fraction Fraction::add(Fraction f) {
    return Fraction(numerator * f.denominator + f.numerator * denominator, denominator * f.denominator);
}
Fraction Fraction::subtract(Fraction f) {
    return Fraction(numerator * f.denominator - f.numerator * denominator, denominator * f.denominator);
}
Fraction Fraction::multiply(Fraction f) {
    return Fraction(numerator * f.numerator, denominator * f.denominator);
}
Fraction Fraction::divide(Fraction f) {
    return Fraction(numerator * f.denominator, denominator * f.numerator);
}
You wished for some style and cleanliness advice, so here are a few things you may improve in that area:


Don't include gcd in you class because it is actually completely unrelated. Instead, write a separate non-class function for it.
Name your parameters. Things such as Fraction add(Fraction); usually imply that the parameter is ignored, and even if the user understands that this is not the case here, it remains unclear what your parameter actually represents.
Include all the headers that you use. Your code is currently missing a #include &lt;string&gt;. 
Do some error checking and assure that parameters are valid. For example, what happens when somebody passes 0 for d to the constructor? You will end up in an infinite loop because your gcd function does not verify that its arguments are not 0.
Avoid C-style casts. C++ offers a variety of casts with clearly defined purposes, whereas the C cast covers a lot of different conversions, some of which you may not want. In your particular case, don't write (double)numerator; write static_cast&lt;double&gt;(numerator) instead (same for denominator, of course).
Instead of having add, subtract, multiply and divide, you should overload the corresponding operators (e.g. operator+ for add). You should also consider adding more operators, such as operator+=, operator-= and so on and so forth.
Don't use std::endl where a simple '\n' would suffice (which is almost always). The reason for this is that std::endl also flushes the underlying buffer which can seriously harm performance when doing lots of IO and is seldom required.
fraction is a bad name for a function that returns a string representation of your class. You could call it to_string for example, or even choose to implement explicit operator std::string().
You can safely omit return 0; at the end of main, the compiler is nice enough to add it automatically.
Currently, your constructor calculates gcd(n, d) twice. You should calculate the value once and then divide set numerator = n / gcd_value and denominator = d / gcd_value instead.
You should consider adding adding a default value of 1 to the second parameter to the constructor to enable construction of fractions from whole numbers easily, i.e. 

Fraction::Fraction(int n, int d = 1);
...
Fraction f {3}; //f represents the fraction 3/1

Don't treat single characters as strings when you don't need to. In your case, replace "/" by '/' in fraction. There is an operator+ in std::string that handles single chars.
Fix the unnecessary whitespace in Fraction (int, int). Judging by how you defined your other methods, it should instead read Fraction(int, int) (I suppose this is just a typo).




Edit: As JPhi1618 pointed out in the comments, it is better to not get into the habit of relying on implicit construction when assigning values to objects. Instead, one should make use of explicit construction and uniform initialization. Accordingly I changed last line of the code sample of point 11 from Fraction f = 3; to its current representation.