Page 1 of 1

friend function and virtual function

Posted: Wed Oct 28, 2009 6:05 am
by ranjitbd

Code: Select all

 
// give me a nice definition of friend function and virtual function
// if possible give me an examlpe...plz dnt refer any site to read documents
 

Re: friend function and virtual function

Posted: Wed Oct 28, 2009 6:24 am
by requinix
I'd give an example but I don't know what programming language you're thinking of.

Re: friend function and virtual function

Posted: Thu Nov 05, 2009 4:56 am
by ranjitbd
tasairis wrote:I'd give an example but I don't know what programming language you're thinking of.
// php programming language

Re: friend function and virtual function

Posted: Thu Nov 05, 2009 9:56 am
by jackpf
I don't believe PHP has friend and virtual functions.

A friend function is able to access all private properties of its friend. A virtual function is able to be "overridden" by another class.

I'm basing this on my C++ knowledge btw.

Also, JW, why are you writing in comments??

Re: friend function and virtual function

Posted: Thu Nov 05, 2009 1:21 pm
by requinix
First of all, let the record show I was being sarcastic. PHP does not have friend or virtual functions so clearly OP was asking about something that wasn't PHP.


Now, technically, PHP does have virtual class methods. It does not have the virtual keyword.
By default all class methods are "virtual" in that descendant classes can override them - the exception is methods declared with the final keyword.