Cannot instantiate abstract class

This keeps happening to me:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class base_room
{
public:
  //==Variables==//
  int w,h;
  std::vector<base_entity*> entities;
  std::vector<base_particle*> particles;
  std::vector<base_tile*> tiles;

  ALLEGRO_BITMAP *Tiles;

  color_map tint;

  std::vector<base_entity*>::iterator it;
  //=============//

  //==Actions====//
  virtual ~base_room() {}

  virtual void Draw() = 0;

  //=============//
};

class room_test1: public base_room
{
  //===Variables==//

  //==!Variables==//

  //===Actions==//
  virtual void Draw()
  {
    for ( it=entities.begin() ; it < entities.end(); it++ )
      (*it)->Draw();
  };
  //==!Actions==//
};


1
2
3
4
5
6
1>c:\users\tyler\documents\visual studio 2010\projects\engine\simplerpg\main.cpp(107): error C2259: 'base_room' : cannot instantiate abstract class
1>          due to following members:
1>          'void base_room::Draw(void)' : is abstract
1>          c:\users\tyler\documents\visual studio 2010\projects\engine\simplerpg\engine.h(267) : see declaration of 'base_room::Draw'
1>
1>Build FAILED.


This keeps happening. I had another class do the same thing then magically fix itself after a million build attempts. Any insight on this issue would be greatly appreciated.
Thanks,
Tyler
By the look of it somewhere in your code you are trying to create an instance of the base_room class which you are not allowed to do (as it has the Draw pure virtual function inside of it making it an abstract class).

Abstract classes are only meant to be derived from, not directly used.
Huh apparently I left a version of it buried in main. Thanks alot.
Topic archived. No new replies allowed.