Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Implementation ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 11 Topic 45637 of 48612
Post > Topic >>

Implementation of free functions inside a class valid?

by =?ISO-8859-1?Q?Marcel_M=FCller?= <news.5.maazl@[EMAIL PROTECTED] > Apr 29, 2008 at 06:23 PM

I found the following code fragment:

template <class T>
class ptr
{private:
   T*  Ptr;
  public:
   // ...

   friend bool operator==(const ptr<T>& l, const ptr<T>& r)
   { return l.Ptr == r.Ptr; }
   friend bool operator==(const ptr<T>& sco, const T* ptr)
   { return sco.Ptr == ptr; }
   friend bool operator==(const T* ptr, const ptr<T>& sco)
   { return sco.Ptr == ptr; }
   friend bool operator!=(const ptr<T>& l, const ptr<T>& r)
   { return l.Ptr != r.Ptr; }
   friend bool operator!=(const ptr<T>& sco, const T* ptr)
   { return sco.Ptr != ptr; }
   friend bool operator!=(const T* ptr, const ptr<T>& sco)
   { return sco.Ptr != ptr; }
};

Obviously free functions are implemented within the class body.
Is this valid? And if it is valid are these functions implicitly inline 
like other function implementations in the class body?


Marcel
 




 11 Posts in Topic:
Implementation of free functions inside a class valid?
=?ISO-8859-1?Q?Marcel_M=F  2008-04-29 18:23:19 
Re: Implementation of free functions inside a class valid?
"Victor Bazarov"  2008-04-29 13:17:44 
Re: Implementation of free functions inside a class valid?
Kai-Uwe Bux <jkherciue  2008-04-30 00:41:21 
Re: Implementation of free functions inside a class valid?
acehreli@[EMAIL PROTECTED  2008-04-29 11:07:37 
Re: Implementation of free functions inside a class valid?
"Victor Bazarov"  2008-04-29 15:34:40 
Re: Implementation of free functions inside a class valid?
Joe Greer <jgreer@[EMA  2008-04-29 22:00:41 
Re: Implementation of free functions inside a class valid?
"Victor Bazarov"  2008-04-29 17:16:50 
Re: Implementation of free functions inside a class valid?
ram@[EMAIL PROTECTED] (S  2008-04-29 22:18:55 
Re: Implementation of free functions inside a class valid?
ram@[EMAIL PROTECTED] (S  2008-04-29 22:55:20 
Re: Implementation of free functions inside a class valid?
galathaea <galathaea@[  2008-04-29 17:35:47 
Re: Implementation of free functions inside a class valid?
galathaea <galathaea@[  2008-04-29 17:39:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 15:29:21 CST 2008.