protected

Is there a use for making a protected destructor virtual?

☆樱花仙子☆ 提交于 2019-12-30 08:08:28
问题 /*Child is inherited from Parent*/ class Parent { public: Parent () //Constructor { cout << "\n Parent constructor called\n" << endl; } protected: ~Parent() //Dtor { cout << "\n Parent destructor called\n" << endl; } }; class Child : public Parent { public: Child () //Ctor { cout << "\nChild constructor called\n" << endl; } ~Child() //dtor { cout << "\nChild destructor called\n" << endl; } }; int main () { Parent * p2 = new Child; delete p2; return 0; } If I make Parent 's destructor virtual,

Is there a use for making a protected destructor virtual?

只愿长相守 提交于 2019-12-30 08:08:05
问题 /*Child is inherited from Parent*/ class Parent { public: Parent () //Constructor { cout << "\n Parent constructor called\n" << endl; } protected: ~Parent() //Dtor { cout << "\n Parent destructor called\n" << endl; } }; class Child : public Parent { public: Child () //Ctor { cout << "\nChild constructor called\n" << endl; } ~Child() //dtor { cout << "\nChild destructor called\n" << endl; } }; int main () { Parent * p2 = new Child; delete p2; return 0; } If I make Parent 's destructor virtual,

Any performance reason to put attributes protected/private?

大憨熊 提交于 2019-12-30 07:10:50
问题 I "learned" C++ at school, but there are several things I don't know, like where or what a compiler can optimize, seems I already know that inline and const can boost a little... If performance is an important thing (gaming programming for example), does putting class attributes not public ( private or protected ) allow the compiler to make more optimized code ? Because all my previous teacher were saying was it's more "secure" or "prevent not wanted or authorized class access/behavior", but

When would I use package-private in Java? [duplicate]

僤鯓⒐⒋嵵緔 提交于 2019-12-30 06:36:07
问题 This question already has answers here : Pros and cons of package private classes in Java? (8 answers) Closed 6 years ago . I love access control in any language, but I find that in Java I almost never (if ever) use the package-private access modifier (or lack thereof). I realize that inner classes can be private , protected , or package-private , but outer classes can only be package-private or public . Why can an outer class be package-private but not protected ? What is the benefit of

C++ why use public, private or protected inheritance?

有些话、适合烂在心里 提交于 2019-12-30 01:10:27
问题 Well there is enough information about this subject. For example this thread was very clear to me: Difference between private, public, and protected inheritance Except one point; Why is it useful? 回答1: Use public inheritance to reflect an is-a relationship . This is the main use for inheritance, especially in combination with virtual functions. It allows re-use of interface, not just of old code by new code, but also re-use of new code by old code! (because of virtual function dispatch at

C++ why use public, private or protected inheritance?

冷暖自知 提交于 2019-12-30 01:10:26
问题 Well there is enough information about this subject. For example this thread was very clear to me: Difference between private, public, and protected inheritance Except one point; Why is it useful? 回答1: Use public inheritance to reflect an is-a relationship . This is the main use for inheritance, especially in combination with virtual functions. It allows re-use of interface, not just of old code by new code, but also re-use of new code by old code! (because of virtual function dispatch at

How to access protected member

六眼飞鱼酱① 提交于 2019-12-28 15:49:48
问题 I have following code in extending type (in F#) which invokes a protected method of a class it inherits from (in C#) but I get the exception (see below). Is there a workaround for this? let getPagereference id = this.ConstructPageReference(id) The member or object constructor 'ConstructPageReference' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda

Using a method to get Embedded Font Causes Protected Memory Error

十年热恋 提交于 2019-12-25 07:44:51
问题 I am using this code to get an embedded font: /// <summary> /// Returns an Embedded Font /// </summary> /// <param name="ImagePath">String begins with namespace e.g MyProgram.Image.png</param> /// <returns></returns> public static Font GetEmbeddedFont(string FontPath, float Size) { Font _font = null; Thread getFontThread = new Thread(() => GetFont(FontPath, Size, out _font)); getFontThread.Start(); getFontThread.Join(); return _font; } #region GetFont private static void GetFont(string

Asp.net Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

ぃ、小莉子 提交于 2019-12-25 04:06:50
问题 After being plagued over a year with the dredded "Attempted to read or write protected memory. This is often an indication that other memory is corrupt", I have finally found a fix on it! Background: asp.net 4.0. Windows server 2003. Using MySQL database. I used to randomly get this issue on a few pages, and coincidently, the pages had an asp.net repeater on it. I tried all sorts of recommendations, but they simply didn't work. 回答1: I was using system.data.odbc , with an odbc driver installed

How to lock Excel cells in VBA?

感情迁移 提交于 2019-12-25 01:47:00
问题 I have an Excel worksheet that acts like an application, with form control buttons allowing users to 'navigate' through records. First, Previous, Next & Last cycle appropriately through one of the worksheets records, displaying the values in my 'form' worksheet. When users are not in Edit or Add Mode, I would like to lock the cells to prevent users from modifying contents. I tried Range("A1:O24").Locked = True, but I am still able to type new values into the cells. Anyone know how to