I have a map in C++ and I wish to input my class as the value, and a string as the key.
When I try to, I get an error 'Scene_Branding' : illegal use of this type as an expression
I get an illegal use of this type as an expression, and I can't seem to find out why. Here is some code.
string CurrentScene = "Scene_Branding";
map<string, Scene> Scenes;
Scenes.insert(std::make_pair("Scene_Branding", Scene_Branding)); //<-- Illegal Error parameter 2
and here is Scene Branding header..
#ifndef Scene_Branding_H
#define Scene_Branding_H
#include "Scene.h"
#include <iostream>
#include <string>
class Scene_Branding : Scene
{
public:
Scene_Branding();
~Scene_Branding();
void Draw();
};
#endif
and here is Scene header..
#ifndef Scene_H
#define Scene_H
#include <iostream>
#include <string>
class Scene
{
public:
Scene();
~Scene();
virtual void Draw();
};
#endif
and here is there cpp files.
Scene cpp.
#include "Scene.h"
Scene::Scene()
{
}
Scene::~Scene()
{
}
void Scene::Draw(){
std::cout << "Hey";
}
Scene_Branding cpp
#include "Scene_Branding.h"
Scene_Branding::Scene_Branding()
{
}
Scene_Branding::~Scene_Branding()
{
}
void Scene_Branding::Draw()
{
std::cout << "Drawing from Scene_branding";
}