Here i am faced with problem in destructor of objects. In the program given below i am trying to make object with the base class pointer dynamically and when i am trying delete that pointer than pointer just delete object of A. So how can i delete all the objects at the end of program?  class A{          public:             A(){             cout&lt;&lt;"Object A is created "&lt;&lt;endl;             }             ~A(){              cout&lt;&lt;"Object A is destroyed"&lt;&lt;endl;              }        }; class B{         public:           B(){           cout&lt;&lt;"object B is Created \n";           }           ~B(){            cout&lt;&lt;"Object B is Destroyed"&lt;&lt;endl;            }        }; class C{         public:           C(){           cout&lt;&lt;"constructor of C class"&lt;&lt;endl;           }           ~C(){            cout&lt;&lt;"destructor of C "&lt;&lt;endl;            }        }; class D:public C, public B, public A{      public:        D(){        cout&lt;&lt;"Object D is created "&lt;&lt;endl;        }        ~D(){         cout&lt;&lt;"Object D is destroyed "&lt;&lt;endl;         }   }; int main() {    A *a;    a = new D();    delete a;    return 0; }
I have a solid understanding of most OOP theory but the one thing that confuses me a lot is virtual destructors. I thought that the destructor always gets called no matter what and for every object in the chain. When are you meant to make them virtual and why?
Order of elements is lcm-closed in abelian groups How can I prove that if $G$ is an Abelian group with elements $a$ and $b$ with orders $m$ and $n$, respectively, then $G$ contains an element whose order is the least common multiple of $m$ and $n$?  It's an exercise from Hungerford's book, but it's not homework. I could not solve it when I take the course on groups and I think it should be easy. There is a hint that says to first prove when $m$ and $n$ are coprimes. I did this part. But I have no idea how to solve the general case.  Thanks. I've noticed that in comments, when you create `code region` with backticks, the backslash will still work as an escape character within that region (but it should not, IMHO).  To clarify:   In comments, `\\` will be rendered as \, but it should be rendered as \\ In the post body itself, `\\` will be rendered as \\ (i.e., correctly)   This is especially confusing when you enter regular expressions into a comment, since backslash-escaping is very common there, and confusion increases if you are dealing with a regex that is double-escaped for representation in a string.   At some point you lose track how many backslashes you must make so the comment renders correctly, or you don't notice fast enough (or at all) and the comment contains wrong code where the same markup in a question or answer would come out as perfectly correct.   It's just that comments can't be corrected anymore after the grace period, leaving you with the choice of either deleting the comment, thus crippling the conversation, or engaging in a trial-and-error game of writing another comment with even more backslashes to explain the issue.  My question is two-fold:   Will this error be corrected? If yes, existing comments should probably be searched and "fixed" by a routine that tries to do the right thing (this is probably somewhere between hard and impossible) Or, can I rest assured that never ever the behavior of the backslash in comments is going to be changed, so I can start working around this issue by hand, knowing that they won't start displaying incorrectly at some point in the future? If you try to execute a program that is not installed you will get a message  The program 'x' is currently not installed. You can install it by typing:  sudo apt-get install x   and instead of offering you to install the program for you, you have to type the actual command. How can this behavior be changed? Deploy Community Builder audience page assignments with ant migration tool? In Community Builder, if you create audiences and assign them to page variations, you cannot deploy these using change sets, according to .  In fact, Audience doesn't even appear in the list of change set components.  On the other hand, Audience metadata can be deployed using the ant migration tool, so I was hopeful that the audience assignments would also be deployable.  Unfortunately, I haven't had success in deploying any audience assignments, either for entire pages or for components on a page.  Has anyone found a workaround for deploying audience assignments for Community Builder pages?  I should say that I'm using the Build Your Own template.  If it can't be deployed, is there at least a way to get a list of audience assignments so I don't have to open every single page in the Community Builder to check?  Here's what I'm using in my package.xml manifest.  All the community builder page variations and all the audiences are created correctly, but the assignments are not.  &lt;types&gt;     &lt;members&gt;*&lt;/members&gt;     &lt;name&gt;Audience&lt;/name&gt; &lt;/types&gt; &lt;types&gt;     &lt;members&gt;*&lt;/members&gt;     &lt;name&gt;CustomSite&lt;/name&gt; &lt;/types&gt; &lt;types&gt;     &lt;members&gt;*&lt;/members&gt;     &lt;name&gt;SiteDotCom&lt;/name&gt; &lt;/types&gt; How to add indicator on a light switch to indicate the outdoor 3-way light is on? Have some carriage lights outside my garage that can be turned on from inside the house. It's common that the switch will get flipped and the lights will stay on when they're not wanted.  Is there some way I can add an indicator to the light switch so I can know if the light is on?  Note: the carriage lights are on a 3 way switch. Understanding the differential $dx$ when doing $u$-substitution Changing website favicon dynamically I have a web application that's branded according to the user that's currently logged in. I'd like to change the favicon of the page to be the logo of the private label, but I'm unable to find any code or any examples of how to do this. Has anybody successfully done this before?  I'm picturing having a dozen icons in a folder, and the reference to which favicon.ico file to use is just generated dynamically along with the HTML page. Thoughts? Which external Javascript libraries work with Lightning Locker Service? Components often seem to work with external libraries until the Locker Service is enabled. What libraries work with locker service enabled and where can I go to find out? How to merge multiple Internet connections into one? My PC has a total of 4 NICs, 2 wired Gigabit Ethernet network cards and also 2 wireless network cards. (One Broadcom with proprietary drivers and Ralink with open source software, which works much better than Broadcom.)  My cellphone can share its connection wirelessly to my PC, but I also have a wired Internet connection. So I have multiple Internet connections to access the Internet. How can I merge 2 or more connections together and balance them to enjoy one unified Internet experience that it is the sum of all Internet connections connected to it.  For example if I have a modem with an Internet connection of 1024kB/s and another one that offers 512kB/s and one small one that offers 128kB/s, after load balancing and merging all connections (Bonding or Teaming), I could download at a speed of 1664kB/s using all 3 Internet connections as one for example.  This question has always intrigued me. I'm trying to find the roots of $x^4+1$. I've already found in this site solutions for polynomials like this $x^n+a$, where $a$ is a negative term. I don't remember how to solve an equation when $a$ is a positive term as the equation above.  Thanks Formula for determinant of block matrix with commuting blocks On , I saw the following formula  $$\det\begin{bmatrix}A &amp; B\\ C &amp; D\end{bmatrix} = \det(AD-BC)$$  if $C$ and $D$ commute. Is this always true?   Or is there a good counter example for each $2 \times 2$ block matrices? Is there an (easy) way to create or personalize .bst files? When you prepare an article for a journal (in my case, Quantum Information and Computation, Rinton Press), often they ask you to use some format for your references; in my case, the following:     [1] R. Calderbank and P. Shor (1996), Good quantum error          correcting codes exist,  Phys. Rev. A, 54, pp. 1098-1106.      [2] M.A. Nielsen and J. Kempe (2001), Separable states   are  more disordered globally than locally, quant-ph/0105090.      [3] A.W. Marshall and I. Olkin (1979), Inequalities:   theory of majorization and its applications, Academic Press (New   York).   The issue is, sometimes (and this is the case) they do not provide a .bst style file for bibtex users. I (and I guess many other people) prefer not to copy all the references of a bibtex file one by one into a tex document. So here is the question I am trying to answer:     What is the easiest way to create a .bst file? (for Rinton or any other publisher)   At first sight, I thought this would be very easy to do: after all, a .bst file is just a mere script to give format to a list. Strangely to me, after a long search I have been unable to find a simple clean solution to this problem. These are the the options I have been looking at:   I have tried to adapt a previous .bst file: concretely, apsrev4-1.bst, which has a similar format. Other people have tried this solution before , . However, it is an ugly option. First, it requires going through the script of the .bst and understanding it. Second, the script format used in different .bst files differs (quite annoyingly), so it is not easy to modify them unless you do understand what's written. The above solution is quite hideous and you really lose time on it, so I was wondering: isn't there any software tool (hopefully with a GUI) that does this job? It should, after all, pretty easy to program for a .bst script expert some sort of program to generate .bst files. There are some related questions in this site asking for something similar , ; there I have seen a couple of proposed apps, but going through their manuals they seem not so easy to use. Isn't there some software tool available to generate a .bst in less than 1 hour of work?   Remarks: ideally I would like to use/personalize/create .bst styles that support eprint fields (e.g. aps4-1.bst). Where has the trailing newline char gone from my command substitution? The following code best describes the situation.  Why is the last line not outputting the trailing newline char?  Each line's output is shown in the comment.  I'm using GNU bash, version 4.1.5          echo -n $'a\nb\n'                  | xxd -p  # 610a620a              x=$'a\nb\n'   ; echo -n "$x" | xxd -p  # 610a620a      echo -ne "a\nb\n"                  | xxd -p  # 610a620a x="$(echo -ne "a\nb\n")" ; echo -n "$x" | xxd -p  # 610a62 Product and sum of positive operators is positive I want to show that for $S,T\in B(H)$ bounded operators on Hilbertspace with $S\geq 0,T\geq 0$ and $ST=TS$,  we have $S+T\geq 0$, and $ST\geq 0$.  $T\geq 0$ means $(Tx,x)\geq 0$.    To me it seems that $((S+T)x,x) = (Sx,x)+(Tx,x)\geq 0$. But for $ST$ i like some help.   There is a theorem in Rudin (12.32) that says that for every $T\in B(H)$ we have an equivalence:   $T$ is positive $\Leftrightarrow$ $T$ is self adjoint, i.e. $T=T^*$ and $\sigma(T)\subset [0,\infty)$.   Since $S, T$ are self adjoint we know that $ST=TS = S^*T^* = T^*S^*$ ($ST$ is selfadjoint since $S,T$ commute). Also I read somewhere that if $S,T $ commute then $\sigma(ST)\subset \sigma(S)\sigma(T)$, but I am not sure if this is true. Clearly I cant prove it, but if it were true by this ''Theorem'' it would follow that $ST \geq 0$.   Is there a more straightforward way? Show that if $f:X\to Y$ is a continuous function if and only if the graph of $f$ is a closed subset of $X\times Y$ How are reserved and formal synonyms? In the dictionary reserved means - not revealing emotions and formal means - prim or stiff. I saw they were synonym in the Google dictionary. What makes these two words similar, I wonder? Horizontal overflow on my profile page Windows 7's PATH and environment variables are corrupted Converting string into datetime Show f is continuous on (0, ∞) iff f is continuous at 1 for a defined function. exercise: Suppose that $f:(0,∞) → R$  satisfies $f(x) - f(y) = f(x/y)$  for all $x,y$ in $(0, ∞)$ and $f(1) = 0$.   Prove f is continuous on $(0, ∞)$ if and only if f is continuous at $1$.    (proof→:) Suppose that $f:(0,∞) → R$ satisfies $f(x) - f(y) = f(x/y)$ for all $x,y$ in $(0, ∞)$ and $f(1) = 0$. Suppose f is continuous on (0,∞), then by definition f is said to be continuous at a point $a$ if for every $ε &gt; 0$  there is a $δ &gt; 0$ such that $|x-a| &lt; δ$ implies $|f(x) - f(a)| &lt; ε$.   Then suppose f is continuous at $1$, then by our defined function  f(x) - f(y) = f(x/y) , we get $|x-1| &lt; δ$ implies $|f(x) - f(1)| = |f(x) - 0| = |f(x)| =  &lt; ε$.   (proof ←) :Suppose that $f$ is continuous at $1$, then we need to show $f$ is continuous on every point $a$ on $(0, ∞)$. Thus, by definition, f is said to be continuous at a point $a$ if for every $ε &gt; 0$ there is a $δ &gt; 0$ such that $|x-a| &lt; δ$ implies $|f(x) - f(a)| &lt; ε$. Thus, $|x-a| &lt; δ → |f(x) - f(a)| = |f(x/a)| &lt; ε$. Then $f$ is continuous on on $(0, ∞)$.  Please can anyone please help me verify this makes sense. If not, can someone please give any feedback/hints. Thank you in advance.