Diffrent types assigment in switch state cases, inside template function
<p>Apple.h</p>

<pre><code>class Apple {
public:
    Apple(int);
    static int typeID;
private:
    int id_;
};
</code></pre>

<p>Apple.cpp</p>

<pre><code>#include "Apple.h"
Apple::Apple(int pID) {
    id_ = pID;
}
</code></pre>

<p>Potato.h, Potato.cpp identical to Apple</p>

<p>Storage.h</p>

<pre><code>#pragma once
#include "Apple.h"
#include "Potato.h"
#include &lt;vector&gt;
class Storage {
public:
    Storage();
    template&lt;typename foodName&gt; void store(foodName * object){
        (*getBasket&lt;foodName&gt;()).push_back(object);
    };
    template&lt;typename foodName&gt; int countSize(){
        return (*getBasket&lt;foodName&gt;()).size();
    };

private:
    std::vector&lt;Apple*&gt; applebasket_;
    std::vector&lt;Potato*&gt; potatobasket_;
    template &lt;typename foodName&gt; std::vector&lt;foodName*&gt; * getBasket(){
        std::vector&lt;foodName*&gt; * result;
        switch(foodName::typeID){
            case 0:
                result = &amp;applebasket_;
                break;
            case 1:
                //result = &amp;potatobasket_;
                break;
        }
        return result;
    } 
};
</code></pre>

<p>Storage.cpp</p>

<pre><code>#include "Storage.h"
int Apple::typeID;
int Potato::typeID;
Storage::Storage() {
    Apple::typeID = 0;
    Potato::typeID =1;
}
</code></pre>

<p>main.cpp</p>

<pre><code>#include "Storage.h"
#include &lt;iostream&gt;
int main() {
    Apple* apple;
    Potato* potato;
    Storage storage;
    int i;
    for(i = 0;i &lt; 7;i++){
        apple = new Apple(i);
        storage.store&lt;Apple&gt;(apple);  
    }      
    std::cout&lt;&lt;storage.countSize&lt;Apple&gt;();
    return 0;
}
</code></pre>

<p>This code works and outputs right size of vector, but if case line in switch statement (inside Storage.h) is uncommented, compiler(g++) throws 
"error: cannot convert ‘std::vector &lt; Potato*>* ' to 'std::vector&lt; Apple*>* ' in assignment". 
It is like compiler trying out both cases anyway, and i cant find is it possible and how to avoid this. 
I need help with this and maybe some advice on a whole thing(one interface for containers of different types), I've started learning C++ recently and probably the way i try this to do here is a total mess. </p>
