MultiLevel Inheritance

A

amir

Here's a scenario:

MainObject
{
ObjectB myB;
myB = new ObjectB(P, true);
}

ObjectA
{
variable v1;
variable v2;
ObjectA(param P)
{
v1 = P.something;
v2 = P.somethingelse;
}
}

ObjectB: ObjectA
{
ObjectC myC;
ObjectB(param P, bool check) : base(P)
{
if(check)
myC = new ObjectC(P);
}
}

ObjectC : ObjectB
{
constructorObjectC(param P): (base P)
{
}
}
==================

I am trying to do the above but I am getting errors. I want to create Object
C only if the boolean is true and not create it otherwise. How can I go about
doing this?

Thanks in advance for your help.
 
J

Jon Skeet [C# MVP]

amir said:
Here's a scenario:

You've written a lot of pseudocode without explaining what you want it
to do. Could you try to write what you want in as close to real C# as
possible? Also explain what you want to achieve.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top