Functie Prietena

Intrebari despre limbajul C++, standardul C++, STL, OOP in C++ sau alte subiecte nelegate de VisualC++
Post Reply
Perseverence
Junior
Junior
Posts: 2
Joined: 18 May 2015, 12:58
Judet: Galaţi

Functie Prietena

Post by Perseverence » 18 May 2015, 13:00

Salut...cum se face o functie prietena care returneaza numitorul unei fractii?



Viorel
Microsoft MVP
Microsoft MVP
Posts: 293
Joined: 13 Jul 2007, 12:26

Re: Functie Prietena

Post by Viorel » 18 May 2015, 22:00

Cred că așa se face:

Code: Select all

class Fracție
{
private:
	int mNumărător;
	unsigned mNumitor;

	friend unsigned Numitor( const Fracție & );
};

unsigned Numitor( const Fracție & f )
{
	return f.mNumitor;
}

Perseverence
Junior
Junior
Posts: 2
Joined: 18 May 2015, 12:58
Judet: Galaţi

Re: Functie Prietena

Post by Perseverence » 19 May 2015, 11:57

merci frumos

Post Reply