Thread: Similarity between friend function and prototype

  1. #1
    Registered User Geetika's Avatar
    Join Date
    Dec 2013
    Posts
    10

    Similarity between friend function and prototype

    Hello guys,
    This might be the wrong place to ask, but if anyone is familiar to JavaScript prototypes..
    Is friend function in C++ the same as prototypes in JavaScript ??

  2. #2
    Registered User Geetika's Avatar
    Join Date
    Dec 2013
    Posts
    10
    ADMIN: Kindly delete this post, as i haven't received any answers yet , moreover this is the wrong place to ask a question related to javascript.

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Actually, no, this is the right place for you to ask about it, although a much better place would be a forum about javascript.
    Devoted my life to programming...

  4. #4
    Registered User Geetika's Avatar
    Join Date
    Dec 2013
    Posts
    10
    Quote Originally Posted by GReaper View Post
    Actually, no, this is the right place for you to ask about it, although a much better place would be a forum about javascript.
    well, i just don't know how to remove this post.. i would like to remove this post .. :\

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Users cannot delete posts themselves - that power lies with the moderators. As far as I understand, posts are only deleted under exceptional circumstances. Your best bet would be to send a PM to a moderator with the request - though I don't know if it will be granted or not.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Prototypes only seem to follow one of the three properties of C++ friend classes.

    C++ Friendship isn't commutative: If class A is a friend of class B, class B is not a friend of class A.
    C++ Friendship isn't transitive: If class A is a friend of class B and class B is a friend of class C, class A is not a friend of class C.
    C++ Friendship isn't inherited: A friend of class Base is not a friend of class Derived. if Base is a friend of class A, Derived is not a friend of Class A.

    Of these, only the first property is emulated by prototypes. Prototypes are a means to implement member-like behavior in JavaScript objects and thus conform better to the notion of Inheritance than Encapsulation, which is what C++ friend classes are all about. So, no.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function Prototype, Function Call, and Function definition
    By dmcarpenter in forum C Programming
    Replies: 9
    Last Post: 04-09-2013, 03:29 AM
  2. Replies: 4
    Last Post: 01-04-2013, 03:10 AM
  3. Function prototype in C
    By Darwin Chan in forum C Programming
    Replies: 4
    Last Post: 01-03-2013, 03:06 AM
  4. Replies: 13
    Last Post: 08-24-2006, 12:22 AM
  5. friend function and friend classes...usage question??
    By actionbasti in forum C++ Programming
    Replies: 2
    Last Post: 10-30-2003, 10:53 PM

Tags for this Thread