Assume I have a hierarchy of classes:  class Shape { };  class Circle : public Shape { }  class Square : public Shape { }  ... hundreds of other shapes continue on...   When given the name of a shape class as a string, I need to instantiate objects of that class.  In java, I can do something like this (pseudo code!)  Shape createShape(String name) {     return new Class.forName(name); }   But in C++, I have to do this:  (pseudo code!)  Shape * createShape(const string &amp;name) {     if (name.compare("Circle") == 0) {           return new Circle();     }     else if (name.compare("Square") == 0) {         return new Square();     }     else if ... //hundreds of else if continues, one for each shape }   Is there any better way in C++ to handle situation like this?
I have a file: Base.h  class Base; class DerivedA : public Base; class DerivedB : public Base;  /*etc...*/   and another file: BaseFactory.h  #include "Base.h"  class BaseFactory { public:   BaseFactory(const string &amp;sClassName){msClassName = sClassName;};    Base * Create()   {     if(msClassName == "DerivedA")     {       return new DerivedA();     }     else if(msClassName == "DerivedB")     {       return new DerivedB();     }     else if(/*etc...*/)     {       /*etc...*/     }   }; private:   string msClassName; };  /*etc.*/   Is there a way to somehow convert this string to an actual type (class), so that BaseFactory wouldn't have to know all the possible Derived classes, and have if() for each one of them? Can I produce a class from this string?   I think this can be done in C# through Reflection. Is there something similar in C++?
Hyphenation of words containing slash How can I tell LaTeX to automatically split up the german word  Kontrast/Rausch-Verhältnis    into   Kontrast/Rausch-|Ver|hält|nis   LaTeX complains that "/" is not a letter. Does D&D 5e have a rule for character knowledge about monsters? In the 3rd and 4th editions of D&amp;D, there were explicit rules for determining if a character knew anything about a monster before them.  In 3rd edition, for example, use of the  skill with a general DC of 10 + the monster's HD allowed for determining one fact, plus one fact per 5 points over the check.  Looking at the Intelligence section of the 5e PHB, I don't see any similar notation.  Does 5e provide any guidance as to when a player could use their out-of-game knowledge about a monster, or when the player might be told things their character would probably know in-game? "Repository doesn't support architecture" when trying to update on Landscape client I remember that the main character is trying to find the group that destroyed his home planet while he was on a mission. His planet was very difficult to live on and the people became expert in martial arts and were the best soldiers in the galaxy. They were mercenaries and often helped against tyrants. There was a very memorable section in at least one book about an initiation task that the main character had to do in that he had to survive in their wilderness for days. He was at some point surrounded in a old building by thousands of poisonous worm/snake creatures that he managed to survive until rescued by the leaders. I estimated the sample covariance matrix $C$ of a sample and get a symmetric matrix. With $C$, I would like to create $n$-variate normal distributed r.n. but therefore I need the Cholesky decomposition of $C$. What should I do if $C$ is not positive definite? How to cut holes in an object using another object? I'm trying to model a M16 but I have a problem with cutting the holes on top of the handguard of the weapon.     As you can see in the picture above, I have tried to cut holes into the handguard (The marked mesh in edit mode) with the object above it (The multiple cylinder one). But I simply can't. I have tried the Boolean modifier but the handguard just disappears and doesn't make any holes. Same with the Knife Project thing. Nothing works, it won't make a hole in it. I also installed the BoolTool 0.2 but that didn't work either...The multiple cylinder object goes invisible and doesn't make any cuts.    In the picture above you can see how I want the cuts to be made. I want the holes of the multiple cylinder object to be there on the handguard when I take it away. Nothing works. The 3 methods I tried with worked on other parts of this model but not on the handguard. It should be the handguards mesh's fault but I can do nothing about it. Is there any solution? Can suspended users post comments? Get notifications? What happens to their reputation? Get a list of dates between two dates Using standard mysql functions is there a way to write a query that will return a list of days between two dates.  eg given 2009-01-01 and 2009-01-13 it would return a one column table with the values:   2009-01-01   2009-01-02   2009-01-03  2009-01-04   2009-01-05  2009-01-06  2009-01-07  2009-01-08   2009-01-09  2009-01-10  2009-01-11  2009-01-12  2009-01-13   Edit: It appears I have not been clear. I want to GENERATE this list. I have values stored in the database (by datetime) but want them to be aggregated on a left outer join to a list of dates as above (I am expecting null from the right side of some of this join for some days and will handle this). Is there an easy method for installing binary builds of glibc? Time and time again I see questions such as these:       And these are the types of solutions we're typically pushing:        Is this really the best we can do? Aren't there binary builds of GLIBC that we can simply unzip into a directory such as /opt/myglibc, and set the $LD_LIBRARY_PATH or whatever and run whatever application we want, without issues?   An application, such as the newer builds of Chrome (28+) that appear to require GLIBC 2.14?  NOTE: This thread titled:  on tecmint.com is what ultimately got me thinking about this.  References Applications Don't Show Up in Spotlight Spotlight has stopped showing any results for my Applications. I've tried reindexing and removing the index so it rebuilds it. No change. I've tried adding Applications to the Privacy tab and removing it, no change.  I tried repairing disk permissions and redoing the above, no change. I've tried removing everything from the index except Applications and then I just get nothing for any search at all (except dictionary entries).  I tried adding a symlink in my homedir to Applications and reindexing, but no change.  Any ideas on what to do?  I'm running Snow Leopard.  This is driving me crazy!  Update: I've noticed that when I start a reindex with sudo mdutil -E / and then immediately do a Spotlight search for an app that the app shows up temporarily until Spotlight gets disabled due to active indexing.  After the indexing is done, the app entries go away. Create SOAP envelope of XML and send it as HttpWebRequest to WebService After reading the great answer for  by @Ben, I am a bit confused by the part &quot; set the relative tail sizes as a control variable, and then you find the formula for the length of the confidence interval conditional on that variable&quot;. I understand this means you need to compute the length of the confidence interval as a function of the relative tail sizes and then minimize the function. However, what exactly is relative tail sizes? Is it the ratio between the areas of the two tails? Also, is there another way to find shortest CI for a given confidence level? For those who are interested, I know there are somewhat relevant results allowing us to compute sample size such that the length of a CI, say 95% CI, does not exceed a certain bound. I have 2 columns in Excel: the first contains a list of employee names who perform function A, and the second contains a list of employee names who perform function B.  What I want is to identify, in one cell, if there is one employee whose name appears in both the first and second columns. It does not have to show which name(s) appears in both columns, it just needs to identify IF there are any names that appear in both columns. I just graduated, and I'm starting a new job soon. My employer has pretty good policy for matching 401(k) contributions, so I want to invest as much as possible, especially during this first year.  My question is: should I invest in a traditional 401(k), a Roth 401(k), or some combination of the two? On the one hand, tax rates may be much higher when I retire, and I might be in a higher tax bracket, so a Roth 401(k) would be good. On the other hand, I might be in a lower tax bracket when I retire, so a traditional 401(k) might be better. It's hard to know where I will stand in 30 years.  Is this the same trade-off as with a traditional / Roth IRA, or is there any other tax difference I should know about? I'm trying to test a page that has an input but really its a drop down list. The user enters text and then a dropdown appears based on what the user inputted. They are groups that are in the database. If I look for these elements before typing anything they dont exist but once I start typing they do exist.  The problem is I cant just type the whole name and then press enter or return because an option has to be selected from the list.  I can press arrow down to get the focus on the item from the list but then if I say enter it doesnt select, it sends that enter to the original element and nothing gets selected.  I can find the select element:  var ddList = driver.FindElement(By.CssSelector(".ui-autocomplete-input")); ddList.SendKeys("Admins");   This is the first time the list appears in the html.  It looks like this:  &lt;li class="ui-menu-item" role="presentation"&gt; I want to power my DIY stuff with a MacBook Pro USB C charger. The label on a charger says that it can provide three different power profiles:    20.2V - 4.3A 9V - 3A 5.2V - 2.4A   There is a ton of information about what USB-C power distribution is capable of, but I can't find any examples of how exactly to do it.   Is there an easy way or workaround to request one of those power profiles without using a microcontroller?  For example, I got apple MacBook Pro charger, apple USB-C cable, and a breakout board like this one: Auto-implemented getters and setters vs. public fields I see a lot of example code for C# classes that does this:  public class Point {     public int x { get; set; }     public int y { get; set; } }   Or, in older code, the same with an explicit private backing value and without the new auto-implemented properties:  public class Point {     private int _x;     private int _y;      public int x {         get { return _x; }         set { _x = value; }     }      public int y {         get { return _y; }         set { _y = value; }     } }   My question is why. Is there any functional difference between doing the above and just making these members public fields, like below?  public class Point {     public int x;     public int y; }   To be clear, I understand the value of getters and setters when you need to do some translation of the underlying data. But in cases where you're just passing the values through, it seems needlessly verbose. If $\,\gcd(a,b) = {\rm lcm}(a,b)\,$ then prove $a=b$ If $\sigma_n=\frac{s_1+s_2+\cdots+s_n}{n}$ then $\operatorname{{lim sup}}\sigma_n \leq \operatorname{lim sup} s_n$ This is a question from the book Methods of Real Analysis by R. R. Goldberg.     If $(s_n)$ is a sequence of real numbers and if $$\sigma_n=\frac{s_1+s_2+\cdots+s_n}{n}$$ then prove that: $\operatorname{{lim sup}}\sigma_n \leq \operatorname{lim sup} s_n$.   I don't have any idea how to start working on this problem. Please help. Thanks. How can I access google.com outside the US? I live in the UK, and whenever I visit google.com I am redirected to google.co.uk, but I want to see my website's rankings on the US version (I presume the results are different). Is there a way to do this?