I am trying to do something that I feel should be more straightforward or maybe my Java knowledge is interfering, but I can't figure it out. All I want to do is make a vector&lt;A&gt; as {aa, bb, cc} where bb and cc are child instances of the base class, A. Each Child class uses the same function name but has a different implementation. So what I want to do is call that implementation during the iteration. Here's my attempt. #include &lt;iostream&gt; #include &lt;vector&gt;  class A {   public:      virtual ~A() = default; };  class B: public A {   public:     int h() {       return 2;     } };  class C: public A {   public:     int h() {       return 3;     } };  int main() {   std::cout &lt;&lt; &quot;hello world&quot; &lt;&lt; std::endl;      // Inheritance   A aa;   B bb;   C cc;    std::vector&lt;A&gt; as {aa, bb, cc};    for (A child: as) {     if (typeid(B) == typeid(child)) {       std::cout &lt;&lt; &quot;child is a B&quot; &lt;&lt; std::endl;       B* child_b_p= static_cast&lt;B*&gt;(&amp;child);       std::cout &lt;&lt; child_b_p -&gt; h() &lt;&lt; std::endl;     }          if (typeid(C) == typeid(child)) {       std::cout &lt;&lt; &quot;child is a C&quot; &lt;&lt; std::endl;       C* child_c_p= static_cast&lt;C*&gt;(&amp;child);       std::cout &lt;&lt; child_c_p -&gt; h() &lt;&lt; std::endl;     }   }    return 0; }  I expect child is a B 2 child is a C 3  I only see hello world. What is a possible workaround for object slicing in this case?
Someone mentioned it in the IRC as the slicing problem.
Where does Minecraft for Windows 10 store its data? Most efficient way to check for DBNull and then assign to a variable? This question comes up occasionally, but I haven't seen a satisfactory answer.  A typical pattern is (row is a DataRow):   if (row["value"] != DBNull.Value)  {       someObject.Member = row["value"];  }   My first question is which is more efficient (I've flipped the condition):    row["value"] == DBNull.Value; // Or   row["value"] is DBNull; // Or   row["value"].GetType() == typeof(DBNull) // Or... any suggestions?    indicates that .GetType() should be faster, but maybe the compiler knows a few tricks I don't?  Second question, is it worth caching the value of row["value"] or does the compiler optimize the indexer away anyway?  For example:    object valueHolder;   if (DBNull.Value == (valueHolder = row["value"])) {}   Notes:   row["value"] exists. I don't know the column index of the column (hence the column name lookup). I'm asking specifically about checking for DBNull and then assignment (not about premature optimization, etc.).   I benchmarked a few scenarios (time in seconds, 10,000,000 trials):  row["value"] == DBNull.Value: 00:00:01.5478995 row["value"] is DBNull: 00:00:01.6306578 row["value"].GetType() == typeof(DBNull): 00:00:02.0138757   Object.ReferenceEquals has the same performance as "=="  The most interesting result? If you mismatch the name of the column by case (for example, "Value" instead of "value", it takes roughly ten times longer (for a string):  row["Value"] == DBNull.Value: 00:00:12.2792374   The moral of the story seems to be that if you can't look up a column by its index, then ensure that the column name you feed to the indexer matches the DataColumn's name exactly.  Caching the value also appears to be nearly twice as fast:  No Caching: 00:00:03.0996622 With Caching: 00:00:01.5659920   So the most efficient method seems to be:   object temp;  string variable;  if (DBNull.Value != (temp = row["value"]))  {       variable = temp.ToString();  } Proving normality of affine schemes One of the exercises in Ravi Vakil's algebraic geometry notes, Ex. $5.4.$I(b), is to show that    $$ \operatorname{Spec}\left(k[x_1, \ldots, x_n]/(x_1^2 + \cdots + x_m^2)\right) $$   is normal, where $k$ is any field of $\operatorname{char}(k)\neq 2$, and $n \geq m \geq 3$.    I have absolutely no idea how to get started on this. Is there anyone that could give a hint as to how one would approach this problem? Reason for strange "canyons" of dust on the cooling platform I took apart my cooling platform Something like this :  And I found something like this inside :       I wonder why around the hollows are the "canyon like" structures.  PS: I also drop this platform on the floor, maybe this could be a reason ?   EDIT :  Everybody seems (except Brandon Enright answer) to ignore the word "dust" in this question. Those structures are not in the plastic itself. It is dust ON the plastic.  Proof :     Completely wiped out with my finger : I see more and more servers that have no domain defined in the /etc/resolv.conf file.  Only a search entry. In what cases is this setup used ? Are there any cases where it must not be used ?  nameserver xxx.xxx.xxx.xxx nameserver yyy.yyy.yyy.yyy nameserver zzz.zzz.zzz.zzz  search domain1 domain2 domain3 ... Evaluating string "3*(4+2)" yield int 18 Is there a function the .NET framework that can evaluate a numeric expression contained in a string and return the result? F.e.:  string mystring = "3*(2+4)"; int result = EvaluateExpression(mystring); Console.Writeln(result); // Outputs 18   Is there a standard framework function that you can replace my EvaluateExpression method with? Prove that vector space and dual space have same dimension As an exercise in my textbook, I need to prove that if $V$ is a finite dimensional vector space with dual space $V^*$ over $\mathbb{R}$, then dim$(V)$=dim$(V^*)$.  Let $\omega\in V^*$ and let $\{e_1,...,e_n\}$ be a basis for $V$. Define $e^i\in V^*$ by $e^i(e_j)=\delta_{ij}$. We show that $\{e^1,...,e^n\}$ spans $V^*$. $\omega(v)=\omega(v_1e_1+...+v_ne_n)=v_1\omega(e_1)+...+v_n\omega(e_n).$ If $\omega(e_1)=\lambda_1,...,\omega(e_n)=\lambda_n$, then $\omega(v)=v_1\lambda_1e^1(e_1)+...+v_n\lambda_ne^n(e_n)$=$\lambda_1e^1(v)+...+\lambda_ne^n(v)$.   To show $\{e^1,...,e^n\}$ is linearly independent, suppose that $0=c_1e^1+...+c_ne^n$ is the zero mapping to $\mathbb{R}$. Consider the image of $e_1:$  $0(e_1)=c_1*1+...+c_n*0=c_1$ Hence, $c_1=0$. Repeating the procedure for $e_j$, $2\leq j\leq n$, we see that $c_1=c_2=...=c_n=0$.  Does this proof look correct?  If the proof is correct, I have an additional small question. It seems like this proof is dependent on the fact that $V$ is a real (or complex) vector space, since we define the covectors to have the image set $\{0,1\}$. Is there a proof that works for vectors spaces over general fields? Site Analytics header does not show the link to "traffic sources" when in that section I was seeing the Site Analytics page (/site-analytics)  (>25K users) and also  and found out that the header is not consistent:   When in history, the header shows "history | traffic sources" When in traffic sources, the header just shows "history"   Graphically: Bootstrap Paradox in Interstellar Are Constitution changes retroactive when calculating max HP? Lets say I'm a fighter that just leveled up to level 4, and decide to bring my Constitution up from 16 to 18. How many hit points do I have?  Level 1 = 10 (base) + 3 (Con mod) = 13.  Level 2 = 10 + 6 (average HP per fighter level) + 3 (Con mod) x 2 = 22  Level 3 = 10 + 6 (average) x 2 + 3 (Con mod) x 3 = 31  Level 4 = 10 + 6 (avg) x 3 + 3 (Con mod) x 3 (3 level-ups) + 4 (increased Con mod, which is now 4) x 1 = 41?  OR  Level 4 = 10 + 6 (avg) x 3 + 4 x 4 (4 times current Con mod) = 44?  If it's the first option, it's simply better to level Constitution up at earlier levels. How to replace a video on YouTube I need to make a small correction in a video I uploaded to YouTube. Googling shows that this is not possible. However, I remember seeing it done before. I posted a comment on a video saying that a certain part of the video was missing. I got a reply back that it was fixed, and when I went to see the video again, it was changed. How was this done? In Captain America: Civil War, T'Challa takes the mantle of the Black Panther after his father is killed. As the Black Panther, he appears to have enhanced abilities.  In , the Russos talk about T'Challa having superpowers and being enhanced during Civil War     JOE: It can absorb the energy, so it’s much harder to damage him as a character, and you can see that in the movie he can take a lot of punishment including bullets to the face. He is very well trained. He’s from one of the wealthiest countries on the planet, so there’s great infrastructure there; very technologically advanced country. So he’s been trained at the highest levels to fight, but he also has his own superpowers, which derive from the mythology of his nation. Those will be explored more in Black Panther, it’s clearly evident when he’s able to fight the Winter Soldier out of costume, and go toe-to-toe with him, that he is an enhanced individual.    In Black Panther, we see that in order to become the Black Panther,       one must imbibe juice from the heart-shaped flower and visit the spirit plane after being buried.   But before this,       T'Challa must have his Black Panther powers removed prior to the ritual combat challenge, which he does twice in the film.   This raises the question of how T'Challa could have possibly become the Black Panther abroad - or if he even really had.  How did Black Panther have his powers during Civil War? Setting up a bicycle for someone with restricted knee articulation My father, now in his 70's, had a left knee replacement several years ago. He has limited movement in that knee - probably about 85 degrees on a good day. His knee can extend fully, but cannot bend as much as it should. As a result, he cannot pedal a bike he cannot get his left leg over the top of the pedal stroke.   He is desperate to get back onto a bike, he knows he won't be ripping up the road and winning races like the old days, but wants the freedom to go for a slow easy rides.    Does anyone have suggestions as to a solution to the problem. We don't mind spending money if we know the solution will work, but he can't afford to throw big money at wild ideas that may or may not work. If we find a solution, a new bike is likely.   We have access several mountain bikes in a range of sizes to trail ideas, and we have all the tools and skills to build bikes up from parts and rearrange things as needed.    EDIT: Thanks everyone - all great suggestions. What am am going to do is got tto the LBS and get hold of a cheap set of short cranks for around $30- probably from a kids bike, in the 120-150 size range, and see if he can ride that. Depending how he goes, I'll try a standard right crank and a short left crank. If all else fails, we will go for the Power Cranks   UPDATE: In case anyone else has similar problems. Got some 152mm cranks for $30. Set an old  mountain bike up with the seat as far back as possible. The old man is able to ride reasonably comfortably, now has a smile from ear to ear - any suggestions how to remove it - doesn't fit with the grumpy old man image :)   Has got me wondering how many people with minor knee problems would benefit from short(er) cranks....... How to get WordPress' hooks/actions run sequence? In what order add_action hooks execute? i.e. init wp_head wp_footer after_theme_setup  etc... ??? ??? ???     EDIT: I've also posted my solution. It is said one should avoid staring at Sun as it can damage the eyes, but it is also said that one should not come out in sun during eclipse as it emits dangerous rays. Is that true? If yes, why? You see him for a split second in the final scene with the Final Order and he has kind of a white beard. I can't find any reference online except Nien Nunb from ROJ. High-Swing Cascode Current Mirror I am currently dealing with current mirrors and came across the circuit shown below, a High-Swing Cascode Current Mirror. I read that this implementation, as the name suggests, has the advantage of a high voltage headroom, since the minimum potential at the drain terminal of M4 is: $$ V_{D4\_min}=V_{DS4}+V_{DS2}=(V_{GS4}-V_{TH})+(V_{GS2}-V_{TH}) $$ So the drain potential at M4 only needs to be twice the overdrive voltage, in case of same transistor dimensions, in order to hold M2 and M4 in saturation. But cannot this be said for many other cascode current mirrors, since that behaviour simply occurs by "stacking" together two transistors (M2 and M4)? Additionally, why is there a connection from the gate of M1 to the drain of M3? I have a hard time understanding whats going on in this circuit, help is greatly appreciated.    EDIT: A bias voltage source is setting the potential at the gate of M3/4. Sorry its not shown in the circuit.  EDIT 2: I just read that the mentioned bias voltage is implemented by a MOSFET in diode configuration, . For further discussion lets call it M5. I've always wondered this - why can't you declare variables after a case label in a switch statement?  In C++ you can declare variables pretty much anywhere (and declaring them close to first use is obviously a good thing) but the following still won't work:  switch (val)   {   case VAL:     // This won't work   int newVal = 42;     break; case ANOTHER_VAL:     ...   break; }     The above gives me the following error (MSC):     initialization of 'newVal' is skipped by 'case' label   This seems to be a limitation in other languages too.  Why is this such a problem? Hide/Show field on list form based on value from another field I need to hide field 'B' when the value in field 'A' is NOT equal to 'Other'.  This is a custom list form.  Is jquery the way to go? How to determine if a string is a valid variable name?