Results 1 to 15 of 15
  1. #1
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy

    Private inheritance

    So basically, the derived class only inherits things from the [php]private:[/php] part of the base class? Yet you need to declare the method in the [php]public:[/php] of the base class?

  2. #2

  3. #3
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    I guess i should speak in engrish

    If i do
    [php]class derived : private base[/php]
    it only inherits things from the [php]private:[/php] of [php]class base[/php] Yet I need to declare the name of the methods in the [php]public:[/php] of [php]class base[/php] but i need to define the methods in [php]private:[/php] of [php]class base[/php]

    moar understandable?

  4. #4
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    I'm not getting this.. are you asking a question or just stating something? That looks like something you can just try by yourself with your IDE. |:

  5. #5
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Im asking.....
    Well.
    Alright. Will test in ide

  6. #6
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    No, that sets the most accessible class in your base class.

    So, doing:
    [php]public Polygon : protected Triangle

    class Triangle {
    public:
    int Sides;

    protected:
    int Colour;

    private:
    bool _Hidden;
    }

    [/php]
    would transform transform the variable (int) 'Sides' to protected, and retain the rest.

  7. #7
    C4P's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    2
    My Mood
    Happy
    use "protected:"

  8. #8
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Quote Originally Posted by C4P View Post
    use "protected:"
    Have you even READ one line of a single post in this thread? (including the thread starter post)

  9. #9
    C4P's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    2
    My Mood
    Happy
    Quote Originally Posted by freedompeace View Post
    Have you even READ one line of a single post in this thread? (including the thread starter post)
    no, but i read the title: "Private inheritance".

  10. #10
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    But what if i have something like this
    [php]class ElectricMotor
    {


    public:
    void StartMotor()
    {
    Accelerate();
    Cruise();
    }
    void StopMotor()
    {
    cout << "motor stopped\n";
    };
    private:
    void Accelerate()
    {
    cout << "accelerate\n";
    }
    void Cruise()
    {
    cout << "cruise\n";
    }
    };

    class Fan : private ElectricMotor
    {
    public:

    void StartFan()
    {
    StartMotor();
    }
    void StopFan()
    {
    StopMotor();
    }
    };
    [/php]

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  11. #11
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,977
    Reputation
    343
    Thanks
    4,324
    My Mood
    Cheeky
    why bother with it? the private and public crap is just for ur ide, when compiled theres no difference in public and private functions >.>
    Ah we-a blaze the fyah, make it bun dem!

  12. #12
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Alright. solbed
    request close

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  13. #13
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Quote Originally Posted by Hell_Demon View Post
    why bother with it? the private and public crap is just for ur ide, when compiled theres no difference in public and private functions >.>
    Ease-of-development, sir.

    Furthermore, there is a difference, although subtle, and of little use when hacking games - host assemblies are not able to view private functions, variables and so on.

  14. #14
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Solbed is solbed mate.
    I do duh code for duh game devving

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  15. #15
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,977
    Reputation
    343
    Thanks
    4,324
    My Mood
    Cheeky
    ~solved & locked~
    Ah we-a blaze the fyah, make it bun dem!

  16. The Following User Says Thank You to Hell_Demon For This Useful Post:

    NextGen1 (08-10-2010)

Similar Threads

  1. Other private serv
    By terence in forum General
    Replies: 6
    Last Post: 12-26-2008, 12:14 PM
  2. Pristontale Private Server
    By Fedaykin in forum General Gaming
    Replies: 19
    Last Post: 06-05-2006, 11:44 AM
  3. Runescape Private Server
    By Paolo1993 in forum General Gaming
    Replies: 20
    Last Post: 02-07-2006, 05:06 PM
  4. Private Servers...
    By arunforce in forum General Gaming
    Replies: 10
    Last Post: 01-14-2006, 06:25 AM