Private inheritance

Posts 1–15 of 15 · Page 1 of 1
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?
lulwut?

|:
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?
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. |:
Im asking.....
Well.
Alright. Will test in ide
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.
use "protected:"
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)
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".
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]
why bother with it? the private and public crap is just for ur ide, when compiled theres no difference in public and private functions >.>
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.
Alright. solbed
request close
Solbed is solbed mate.
I do duh code for duh game devving
Posts 1–15 of 15 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us