overloading function

Hi everyone, i was just wondering how to overload this function where the first number is an int, and the second number is a fraction, thanks for any help.

 
friend fraction operator*(fraction f1);


1
2
3
4
5
6
7
8
fraction operator*(fraction f1)
{
	fraction temp;
	
	temp.num = 

	return temp;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef fraction_h
#define fraction_h

class fraction
{
private:
	int num;
	int den;

public:
	fraction();
	fraction(int n);
	fraction operator+(fraction f1);
	fraction operator*(fraction f1);
	fraction operator*(int f1);
	friend fraction operator*(fraction f1);
	bool operator>(fraction f1);
	void read();
	void display();
};

#endif 
1
2
3
4
friend fraction operator * (int l,const fraction& r)
{
  // ...
}
Last edited on
thank ya, my brain was done last night, very easy lol.
Topic archived. No new replies allowed.