c++ Delete inherited member variable in child class





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-6















Consider the following code:



Struct Base 
{
int x;
double y;
}

Struct A : public Base
{
}

Struct B : public Base
{ //here I don't want x (Base::x) to be inherited.
// is there a way to delete it (something like delete Base::x)
}

Struct C : public Base
{
}


What is considered best practice to achieve such a task? x should be inherited by A and C, (and maybe by many other classes) so I can't put it in the private section of Base. The only way I see is to remove x from Base and put it in A & C. But there should be another way right? Thanks.










share|improve this question


















  • 7





    If B shouldn't have Base::x, then B shouldn't inherit publicly from Base.

    – JBL
    Jan 3 at 12:04






  • 1





    Why is B a Base if it doesn't want a x? Perhaps you have a "BaseX" and "BaseY" concept struggling to happen. Or perhaps they should be contained, when needed, not inherited?

    – doctorlove
    Jan 3 at 12:06













  • BTW: why the downvotes?

    – Stephan Lechner
    Jan 3 at 12:23











  • @doctorlove consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't wantm_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:38








  • 1





    @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:40




















-6















Consider the following code:



Struct Base 
{
int x;
double y;
}

Struct A : public Base
{
}

Struct B : public Base
{ //here I don't want x (Base::x) to be inherited.
// is there a way to delete it (something like delete Base::x)
}

Struct C : public Base
{
}


What is considered best practice to achieve such a task? x should be inherited by A and C, (and maybe by many other classes) so I can't put it in the private section of Base. The only way I see is to remove x from Base and put it in A & C. But there should be another way right? Thanks.










share|improve this question


















  • 7





    If B shouldn't have Base::x, then B shouldn't inherit publicly from Base.

    – JBL
    Jan 3 at 12:04






  • 1





    Why is B a Base if it doesn't want a x? Perhaps you have a "BaseX" and "BaseY" concept struggling to happen. Or perhaps they should be contained, when needed, not inherited?

    – doctorlove
    Jan 3 at 12:06













  • BTW: why the downvotes?

    – Stephan Lechner
    Jan 3 at 12:23











  • @doctorlove consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't wantm_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:38








  • 1





    @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:40
















-6












-6








-6








Consider the following code:



Struct Base 
{
int x;
double y;
}

Struct A : public Base
{
}

Struct B : public Base
{ //here I don't want x (Base::x) to be inherited.
// is there a way to delete it (something like delete Base::x)
}

Struct C : public Base
{
}


What is considered best practice to achieve such a task? x should be inherited by A and C, (and maybe by many other classes) so I can't put it in the private section of Base. The only way I see is to remove x from Base and put it in A & C. But there should be another way right? Thanks.










share|improve this question














Consider the following code:



Struct Base 
{
int x;
double y;
}

Struct A : public Base
{
}

Struct B : public Base
{ //here I don't want x (Base::x) to be inherited.
// is there a way to delete it (something like delete Base::x)
}

Struct C : public Base
{
}


What is considered best practice to achieve such a task? x should be inherited by A and C, (and maybe by many other classes) so I can't put it in the private section of Base. The only way I see is to remove x from Base and put it in A & C. But there should be another way right? Thanks.







c++ inheritance






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 12:01









GaetanGaetan

1858




1858








  • 7





    If B shouldn't have Base::x, then B shouldn't inherit publicly from Base.

    – JBL
    Jan 3 at 12:04






  • 1





    Why is B a Base if it doesn't want a x? Perhaps you have a "BaseX" and "BaseY" concept struggling to happen. Or perhaps they should be contained, when needed, not inherited?

    – doctorlove
    Jan 3 at 12:06













  • BTW: why the downvotes?

    – Stephan Lechner
    Jan 3 at 12:23











  • @doctorlove consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't wantm_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:38








  • 1





    @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:40
















  • 7





    If B shouldn't have Base::x, then B shouldn't inherit publicly from Base.

    – JBL
    Jan 3 at 12:04






  • 1





    Why is B a Base if it doesn't want a x? Perhaps you have a "BaseX" and "BaseY" concept struggling to happen. Or perhaps they should be contained, when needed, not inherited?

    – doctorlove
    Jan 3 at 12:06













  • BTW: why the downvotes?

    – Stephan Lechner
    Jan 3 at 12:23











  • @doctorlove consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't wantm_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:38








  • 1





    @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:40










7




7





If B shouldn't have Base::x, then B shouldn't inherit publicly from Base.

– JBL
Jan 3 at 12:04





If B shouldn't have Base::x, then B shouldn't inherit publicly from Base.

– JBL
Jan 3 at 12:04




1




1





Why is B a Base if it doesn't want a x? Perhaps you have a "BaseX" and "BaseY" concept struggling to happen. Or perhaps they should be contained, when needed, not inherited?

– doctorlove
Jan 3 at 12:06







Why is B a Base if it doesn't want a x? Perhaps you have a "BaseX" and "BaseY" concept struggling to happen. Or perhaps they should be contained, when needed, not inherited?

– doctorlove
Jan 3 at 12:06















BTW: why the downvotes?

– Stephan Lechner
Jan 3 at 12:23





BTW: why the downvotes?

– Stephan Lechner
Jan 3 at 12:23













@doctorlove consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't wantm_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

– Gaetan
Jan 3 at 12:38







@doctorlove consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't wantm_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

– Gaetan
Jan 3 at 12:38






1




1





@Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

– Fantastic Mr Fox
Jan 3 at 12:40







@Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

– Fantastic Mr Fox
Jan 3 at 12:40














2 Answers
2






active

oldest

votes


















2














There is no way to "delete" inherited data members, and you cannot even hide them. They get intrinsic part of the subclass.
If B shall inherit just parts of Base, you need to split Base:



Struct Base 
{
double y;
}

Struct BaseWithX : public Base
{
int x;
}

Struct A : public BaseWithX
{ }

Struct B : public Base
{ }

Struct C : public BaseWithX
{ }





share|improve this answer
























  • Thanks Stephan, maybe c++18 should introduce such a delete x, to allow partial inheritance. If you consider the restaurant example I've mentioned above, it is quite annoying to create a new base class just to prevent inheritance of a single member variable

    – Gaetan
    Jan 3 at 12:45








  • 1





    @Gaetan Trouble is, your described use case does not really abide by the principles of OOP, so it's not likely to be a use case that the language caters for in its implementation of inheritance. You're basically falling into the circle-ellipse trap, but a little worse: there is no reason for "food" to be a kind of "restaurant".

    – Lightness Races in Orbit
    Jan 3 at 13:10





















2














Public inheritance makes an is-a relationship. That means B is a Base. And that means if Base has x then since B is a Base, B will have x. You need to re-think this design if you have that problem. Consider switching the relationship between B and Base to composition:



struct B {
void some_function_using_base();
private:
Base base_;
};





share|improve this answer


























  • consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't want m_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:39













  • @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:43












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54021904%2fc-delete-inherited-member-variable-in-child-class%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














There is no way to "delete" inherited data members, and you cannot even hide them. They get intrinsic part of the subclass.
If B shall inherit just parts of Base, you need to split Base:



Struct Base 
{
double y;
}

Struct BaseWithX : public Base
{
int x;
}

Struct A : public BaseWithX
{ }

Struct B : public Base
{ }

Struct C : public BaseWithX
{ }





share|improve this answer
























  • Thanks Stephan, maybe c++18 should introduce such a delete x, to allow partial inheritance. If you consider the restaurant example I've mentioned above, it is quite annoying to create a new base class just to prevent inheritance of a single member variable

    – Gaetan
    Jan 3 at 12:45








  • 1





    @Gaetan Trouble is, your described use case does not really abide by the principles of OOP, so it's not likely to be a use case that the language caters for in its implementation of inheritance. You're basically falling into the circle-ellipse trap, but a little worse: there is no reason for "food" to be a kind of "restaurant".

    – Lightness Races in Orbit
    Jan 3 at 13:10


















2














There is no way to "delete" inherited data members, and you cannot even hide them. They get intrinsic part of the subclass.
If B shall inherit just parts of Base, you need to split Base:



Struct Base 
{
double y;
}

Struct BaseWithX : public Base
{
int x;
}

Struct A : public BaseWithX
{ }

Struct B : public Base
{ }

Struct C : public BaseWithX
{ }





share|improve this answer
























  • Thanks Stephan, maybe c++18 should introduce such a delete x, to allow partial inheritance. If you consider the restaurant example I've mentioned above, it is quite annoying to create a new base class just to prevent inheritance of a single member variable

    – Gaetan
    Jan 3 at 12:45








  • 1





    @Gaetan Trouble is, your described use case does not really abide by the principles of OOP, so it's not likely to be a use case that the language caters for in its implementation of inheritance. You're basically falling into the circle-ellipse trap, but a little worse: there is no reason for "food" to be a kind of "restaurant".

    – Lightness Races in Orbit
    Jan 3 at 13:10
















2












2








2







There is no way to "delete" inherited data members, and you cannot even hide them. They get intrinsic part of the subclass.
If B shall inherit just parts of Base, you need to split Base:



Struct Base 
{
double y;
}

Struct BaseWithX : public Base
{
int x;
}

Struct A : public BaseWithX
{ }

Struct B : public Base
{ }

Struct C : public BaseWithX
{ }





share|improve this answer













There is no way to "delete" inherited data members, and you cannot even hide them. They get intrinsic part of the subclass.
If B shall inherit just parts of Base, you need to split Base:



Struct Base 
{
double y;
}

Struct BaseWithX : public Base
{
int x;
}

Struct A : public BaseWithX
{ }

Struct B : public Base
{ }

Struct C : public BaseWithX
{ }






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 12:21









Stephan LechnerStephan Lechner

29.5k42244




29.5k42244













  • Thanks Stephan, maybe c++18 should introduce such a delete x, to allow partial inheritance. If you consider the restaurant example I've mentioned above, it is quite annoying to create a new base class just to prevent inheritance of a single member variable

    – Gaetan
    Jan 3 at 12:45








  • 1





    @Gaetan Trouble is, your described use case does not really abide by the principles of OOP, so it's not likely to be a use case that the language caters for in its implementation of inheritance. You're basically falling into the circle-ellipse trap, but a little worse: there is no reason for "food" to be a kind of "restaurant".

    – Lightness Races in Orbit
    Jan 3 at 13:10





















  • Thanks Stephan, maybe c++18 should introduce such a delete x, to allow partial inheritance. If you consider the restaurant example I've mentioned above, it is quite annoying to create a new base class just to prevent inheritance of a single member variable

    – Gaetan
    Jan 3 at 12:45








  • 1





    @Gaetan Trouble is, your described use case does not really abide by the principles of OOP, so it's not likely to be a use case that the language caters for in its implementation of inheritance. You're basically falling into the circle-ellipse trap, but a little worse: there is no reason for "food" to be a kind of "restaurant".

    – Lightness Races in Orbit
    Jan 3 at 13:10



















Thanks Stephan, maybe c++18 should introduce such a delete x, to allow partial inheritance. If you consider the restaurant example I've mentioned above, it is quite annoying to create a new base class just to prevent inheritance of a single member variable

– Gaetan
Jan 3 at 12:45







Thanks Stephan, maybe c++18 should introduce such a delete x, to allow partial inheritance. If you consider the restaurant example I've mentioned above, it is quite annoying to create a new base class just to prevent inheritance of a single member variable

– Gaetan
Jan 3 at 12:45






1




1





@Gaetan Trouble is, your described use case does not really abide by the principles of OOP, so it's not likely to be a use case that the language caters for in its implementation of inheritance. You're basically falling into the circle-ellipse trap, but a little worse: there is no reason for "food" to be a kind of "restaurant".

– Lightness Races in Orbit
Jan 3 at 13:10







@Gaetan Trouble is, your described use case does not really abide by the principles of OOP, so it's not likely to be a use case that the language caters for in its implementation of inheritance. You're basically falling into the circle-ellipse trap, but a little worse: there is no reason for "food" to be a kind of "restaurant".

– Lightness Races in Orbit
Jan 3 at 13:10















2














Public inheritance makes an is-a relationship. That means B is a Base. And that means if Base has x then since B is a Base, B will have x. You need to re-think this design if you have that problem. Consider switching the relationship between B and Base to composition:



struct B {
void some_function_using_base();
private:
Base base_;
};





share|improve this answer


























  • consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't want m_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:39













  • @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:43
















2














Public inheritance makes an is-a relationship. That means B is a Base. And that means if Base has x then since B is a Base, B will have x. You need to re-think this design if you have that problem. Consider switching the relationship between B and Base to composition:



struct B {
void some_function_using_base();
private:
Base base_;
};





share|improve this answer


























  • consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't want m_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:39













  • @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:43














2












2








2







Public inheritance makes an is-a relationship. That means B is a Base. And that means if Base has x then since B is a Base, B will have x. You need to re-think this design if you have that problem. Consider switching the relationship between B and Base to composition:



struct B {
void some_function_using_base();
private:
Base base_;
};





share|improve this answer















Public inheritance makes an is-a relationship. That means B is a Base. And that means if Base has x then since B is a Base, B will have x. You need to re-think this design if you have that problem. Consider switching the relationship between B and Base to composition:



struct B {
void some_function_using_base();
private:
Base base_;
};






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 12:36

























answered Jan 3 at 12:10









Fantastic Mr FoxFantastic Mr Fox

19k1971131




19k1971131













  • consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't want m_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:39













  • @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:43



















  • consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't want m_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

    – Gaetan
    Jan 3 at 12:39













  • @Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

    – Fantastic Mr Fox
    Jan 3 at 12:43

















consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't want m_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

– Gaetan
Jan 3 at 12:39







consider a base class RestaurantBase which has among other member a member m_teaspoon. Every restaurant classes (Struct ItaliaFood {}, Struct FrenchFood {}, etc) inherit from RestaurantBase. Now there is some Japanese restaurant (Struct JapanFood {}), which is also a restaurant but doesn't have any teaspoon. So for it I don't want m_teaspoon to be inherited. But it is a restaurant and should inherit the 100 others members of RestaurantBase

– Gaetan
Jan 3 at 12:39















@Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

– Fantastic Mr Fox
Jan 3 at 12:43





@Gaetan Read Scott Meyors effective c++ - Item 34. Differentiate between inheritance of interface and inheritance of implementation. By having teaspoon as part of your interface you are forcing this implementation detail on the children of your base class. Consider making utensils and abstract part of the interface.

– Fantastic Mr Fox
Jan 3 at 12:43


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54021904%2fc-delete-inherited-member-variable-in-child-class%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory