how can i do this in csharp?

  • Thread starter Thread starter thxBruin
  • Start date Start date
T

thxBruin

I have a c++ class like this:
class b : private a{...}

and now i want to convert it to csharp, but i don't know how can i do it by
csharp. When i build a test.cs like this:
Class b: private a{...}
vs2003 said error:cs1031 and cs1519.
 
There are no different types of inheritance in C# -- it's
always public. So, you would have:

class b : a
{
....
}

VR
 
class b {
private void a() {
}
}

The above will create a class named b with a private void method named a.
 
private inheritance in C++ is essentially just syntactic sugar for
composition. Just use

class b
{
private a myA;
}

and whereever you want to make a call to the "a" class methods, just call
the myA variable's methods instead.
 
Back
Top