Private inheritance in C#??

  • Thread starter Thread starter John Sparrow
  • Start date Start date
J

John Sparrow

Just looking for confirmation: the only type of class interitance in C# is
public, right?

I can't find anywhere in the docs where this is explicitly stated. But I'm
assuming they've abandoned the complexities of C++ private inheritance.

This certainly doesn't work:

public class Tester : private MyBase {}

Thanks,

John
 
John,

You are right, public inheritance is the only kind supported in C#.

Hope this helps.
 
Dont know if this is what you're after but you dont
specify the level of access when inheriting.

Eg:

public class MyClass1: MyClass2
{
}

I have never seen it specified anywhere that you can't
inherit from private classes. To be honest I haven't tried
it, but i'm sure this will help if your query is purely
syntax based.

jax
 
My bad, listen to Nick, he's cleverer then I.
-----Original Message-----
Dont know if this is what you're after but you dont
specify the level of access when inheriting.

Eg:

public class MyClass1: MyClass2
{
}

I have never seen it specified anywhere that you can't
inherit from private classes. To be honest I haven't tried
it, but i'm sure this will help if your query is purely
syntax based.

jax

.
 
Jax,

Not really. I just get lucky sometimes.

The original poster wanted to do something different though. He/she/it
wanted to derive in a private manner, meaning that by default, all members
of the base class are private/protected, as opposed to them being exposed
publically.
 
"It"????? grin.

I remember debates when I was a C++ programmer about the value (or lack of)
of private inheritance - as opposed to a private member object.

I used to think C++ was really cool... until I worked on a project where a
guy had overloaded all the operators to make + and - do totally bizarre, and
unintuitive, things! (ok, that's still possible with C#, but I live in
hope...grin).

I still think C++ is a great language, but it does tend to encourage
intellectual masturbation...

Thanks for the clarification,

John
(*he*!)
 
Even C# is subject to bizarre programming styles, lol...

and the whole "IT" thing... maybe its the "IT"s that are overloading
operators with unintuitive usage...
 
Back
Top