I am trying to create a state machine. I have created a class called BaseState that all states inherits from. The problem I'm having is that when the sub classes change a BaseState member variable, it does not change the variable for all of the inherited classes. From what I know of programming, this is when I use static. But in my case I get a linker error (LNK2001).  So when I call ChangeState(State::MenuState); inside SplashState, it switches, but switches back since the value in BaseState has not changed.  class StateMachine { private:     State                   _currentState;     std::vector&lt;BaseState*&gt; _baseStates;     void ProcessStateRequest();  public:     StateMachine(InitVar initVar);     ~StateMachine();      void Update(float deltaTime); };   That adds the states like this:  StateMachine::StateMachine(InitVar initVar) {     _currentState = State::SPLASHSTATE;      for (int i = 0; i &lt; State::EXITSTATE; i++)     {         switch (i)         {         case SPLASHSTATE:         {             _baseStates.push_back(new SplashState(initVar));             break;         }         case MENUSTATE:         {             _baseStates.push_back(new MenuState(initVar));             break;         }         case PLAYSTATE:         {             _baseStates.push_back(new PlayState(initVar));             break;         }         case OPTIONSSTATE:         {             _baseStates.push_back(new OptionsState(initVar));             break;         }         }     } }   With changing states like this:  void StateMachine::ProcessStateRequest() {     //if currentState does not match with the new requested state.     if (_currentState != _baseStates[_currentState]-&gt;GetNewStateRequest())     {         _baseStates[_currentState]-&gt;OnStateExit();         _currentState = _baseStates[_currentState]-&gt;GetNewStateRequest();         _baseStates[_currentState]-&gt;OnStateEnter();     } }   Inside basestate.h:  enum State {     SPLASHSTATE,     MENUSTATE,     PLAYSTATE,     OPTIONSSTATE,     EXITSTATE, };  class BaseState { private:     State               _newStateRequest; //Cannot edit this from subclasses. Adding static causes linker error. protected:     ObjectHandler*      _objectHandler;     UIHandler*          _uiHandler;      void ChangeState(State newState); public:     BaseState(InitVar initVar);     ~BaseState();      virtual void Update(float deltaTime) = 0;     virtual void OnStateEnter() = 0;     virtual void OnStateExit() = 0;      State GetNewStateRequest()const; };   The last part of basestate.cpp:  BaseState::BaseState(InitVar initVar) {     _objectHandler      = initVar.objectHandler;     _uiHandler          = initVar.uiHandler;     _newStateRequest    = SPLASHSTATE; }  BaseState::~BaseState() {}  void BaseState::ChangeState(State newState) {     _newStateRequest = newState; }  State BaseState::GetNewStateRequest() const {     return _newStateRequest; }
Can anyone explain why following code won't compile? At least on g++ 4.2.4.  And more interesting, why it will compile when I cast MEMBER to int?  #include &lt;vector&gt;  class Foo {   public:       static const int MEMBER = 1;   };  int main(){       vector&lt;int&gt; v;       v.push_back( Foo::MEMBER );       // undefined reference to `Foo::MEMBER'     v.push_back( (int) Foo::MEMBER ); // OK       return 0; }
I want to prove that the distance between incentre and orthocentre is $$\sqrt{2r^2-4R^2\cos A\cos B\cos C} $$here $r$ is inradius and $R$ is circumradius. I considered $\triangle API$ ($P$ is orthocentre and $I$ is incentre). I could find  $AP=2R\cos A$, $AI=4R\sin\frac{B}{2}\sin\frac{C}{2} $ and $\angle PAI=\angle \frac{B-C}{2}$. So applying cosine rule I got $$PI^2=4R^2+16R^2\sin^2\frac{B}{2}\sin^2\frac{C}{2} -16R^2\cos A\sin\frac{B}{2}\sin\frac{C}{2}\Bigg(\cos\frac{B}{2}\cos\frac{C}{2}+\sin\frac{B}{2}\sin\frac{C}{2}\Bigg)$$ How to proceed form here ? AMD GPU Material in "material preview mode" and "rendered mode", is entirely gray as background. Only outline is displayed Splitting a semicolon-separated string to a dictionary, in Python I have a string that looks like this:  "Name1=Value1;Name2=Value2;Name3=Value3"   Is there a built-in class/function in Python that will take that string and construct a dictionary, as though I had done this:  dict = {     "Name1": "Value1",     "Name2": "Value2",     "Name3": "Value3" }   I have looked through the modules available but can't seem to find anything that matches.    Thanks, I do know how to make the relevant code myself, but since such smallish solutions are usually mine-fields waiting to happen (ie. someone writes: Name1='Value1=2';) etc. then I usually prefer some pre-tested function.  I'll do it myself then. How to pass the values from one activity to previous activity Is any aspect of the supernatural testable? What level of proof is possible for the supernatural? Are there any drawbacks to legacy BIOS as opposed to UEFI? Are there any drawbacks to installing Ubuntu 13.10 (and soon 14.04) in Legacy BIOS instead of UEFI?  I have installed 13.10 64bit in Legacy by mistake and was just wondering if it would hurt anything to simply leave it there as is?  EDIT  Everything seems to be running just fine in Legacy and all my drivers work. If $a,b,c$ are positive real numbers, not all equal, prove that  $$\dfrac{bc}{b+c}+\dfrac{ca}{c+a}+\dfrac{ab}{a+b}&lt;\dfrac{a+b+c}{2}$$  Progress: $\frac{bc}{b+c}-\frac{b+c}{2}=$ How is it, that $\sqrt{x^2}$ is not $ x$, but $|x|$? Command to switch to tty1? I want to make a list of commands to install everything so it's easier the next time I do it, however, I wanted one of the commands to do CTRL+ALT+F1 for me. How are one-time pads distributed? It seems that OTP encryption is unbreakable. I have read some articles (Wikipedia, Blogpost, etc.), but I could not find any information about how they are used.  If I wanted to create a messenger service, how would I distribute the OTP keys? Both the sender and the receiver need this key before the message is sent, right?   And how do I make sure no one else gets these keys? Why did the Emperor remain motionless while Darth Vader threw him off the balcony? I'm wondering whether this was a movie sin but his body position seemed to stay the same? Also why didn't he stop using Force Lightning? He continued to use it even as he was falling down.   I'm also wondering whether Palpatine meant to electrocute Vader or was it just a coincidence (because he kept firing Force Lightning) .  It makes no sense as he just stood there allowing Vader to throw him. Repeated Iteration of a 2x2 matrix Suppose I am given a $2$x$2$ matrix $A=$ \begin{pmatrix} a &amp; b \\ c &amp; d \end{pmatrix}  And an initial vector $x_n$ = \begin{pmatrix} x_0 \\ y_0\end{pmatrix}.  Under repeated iteration $x_{n+1} = Ax_n$, we find that $x_{n+1}$ converges to a line in the direction of the $eigenvector$  of $A$ of the form $X$= $[u,mu]$ where $m$ is the slope of the line.  I know that this process somehow also involves the largest $eigenvalue, \lambda,$ of $A$, though I am unsure how it connects.  My question is: How does the largest eigenvalue connect to this repeated iteration, how do I find the slope of the line of convergence $m$, and what is meant by the "direction of the eigenvector"? Question:   Answer:   The question was closed at 11:57:57 (according to the hover-over-"x-mins-ago" bar) and the answer was posted at 12:16:35. It's a fairly lengthy answer, so it's possible that it was started to be written before it was closed but I swear I've started to answer a question then I got a banner along the top saying "this question has been closed" and the answer was no longer post-able. How Do I Compute the Eigenvalues of a Small Matrix? If I have a $2\times 2$ or $3\times 3$ matrix, how should I go about computing the eigenvalues and eigenvectors of the matrix?  NB: I am making this question to provide a unified answer to questions about eigenvalues of small matrices so that all of the specific examples that come up can be marked as duplicates of this post. See . How do I hide an element when printing a web page? notation of distribution I have a question:      Does  $$N(0, x)$$ mean a normal distribution with mean $0$ and variance $x$? Or standard deviation $x$?   The notation seems ambiguous sometimes. on StackOverflow, I asked a . There are many good answers but I can not accept just one of it. I would prefer to create my own answer where I summarize all answers. Is that allowed? How to increase the Java stack size? I have found that for only one page (so far) the spacing between the header and content is different from the spacing on all the other pages. You can see this behavior in the images below (from pages 2 and 3 of the document):     My .tex file contents are shown below.  \documentclass[a4paper]{report} \usepackage{fullpage} \usepackage{lipsum} \usepackage{fancyhdr} \pagestyle{fancy} \setlength{\headsep}{0.5cm}  \begin{document} \renewcommand{\headrulewidth}{0.4pt} \renewcommand{\chaptermark}[1]{\markboth{\thechapter. #1}{}} \fancyhead[L]{\bfseries \leftmark} \fancyhead[R]{\bfseries \rightmark}  \chapter{Version Control} \lipsum \lipsum \lipsum \lipsum  \end{document} Is it possible to perform a complete reinstall on an Android smartphone? I occasionally perform such a reinstall on my Windows PC. I repartition my hard drive, format the partitions, and then install Windows on a blank partition. Can this be done on an Android smartphone? (I have an unlocked Sony Xperia S.)