Quote Originally Posted by nvoigt View Post
Can you give a real world example for this? With real classnames so we can maybe suggest a better solution? Right now I don't even know what you are trying to do
Code:
#ifndef GRID_H_
#define GRID_H_

#include<vector>
#include<memory>
#include<random>
#include<ctime>

template <class T> class Grid{
	static std::vector<std::vector<std::shared_ptr<T>>> cell_grid;
public:
	Grid() {
		
	        cell_grid = std::vector<std::vector<std::shared_ptr<T>>> 
			(20, std::vector<std::shared_ptr<T>>(20, nullptr));
						
	}
	virtual ~Grid() {}

};

#endif

#ifndef BUG_H_
#define BUG_H_

#include "grid.h"
#include<memory>

class Bug : Grid<Bug>{
	int x_position, y_position;
public:
	Bug() : x_position(0), y_position(0) {}
	Bug(const int &x_pos, const int &y_pos){
		this->x_position = x_pos;
		this->y_position = y_pos;
	}
	~Bug() {}

	std::shared_ptr<Bug> factory(const Bug &object){

		return std::shared_ptr<Bug>(new Bug(object));
	}
};

#endif

#ifndef ANT_H_
#define ANT_H_

#include "grid.h"
#include<memory>

class Ant : Grid<Ant>{
	int x_position, y_position;
public:
	Ant() : x_position(0), y_position(0) {}
	Ant(const int &x_pos, const int &y_pos){
		this->x_position = x_pos;
		this->y_position = y_pos;
	}
	~Ant() {}

	std::shared_ptr<Ant> factory(const Ant &object){

		return std::shared_ptr<Ant>(new Ant(object));
	}
};

#endif
This is a real world example of what I would like to do. Grid is the base class, Bug and Ant are the derived classes. Presently, the only compiler problem relates directly and only to the static vector declaration which is what I am trying to solve.

I am open to class redesign according to best practices.