I get this error when using c++. I tried other solutions such as using a shared pointer but with no avail. Here is my code :
Main.cpp:
int main() {
game_init();
cout << items.at(0).name << endl;
while(true) game_tick();
return 0;
}
Item.h:
#ifndef ITEM_H
#define ITEM_H
#include "../Rooms/Room.h"
#include <string>
#include <vector>
#include <memory>
using namespace std;
class Item {
public :
Room location;
string name, desc;
//Item(string, string, Room);
virtual void use() = 0;
};
vector <Item> items;
/*
Item::Item(string in_name, string in_desc, Room in_location) {
name = in_name;
desc = in_desc;
location = in_location;
}*/
#endif
Items.h:
#ifndef ITEMS_H
#define ITEMS_H
#include "OldKey.h"
#include <memory>
#include <vector>
vector <shared_ptr<Item>> all_items;
OldKey old_key;
void items_init() {
items.push_back(old_key);
}
#endif
The error is Invalid New Expression of Abstract class Type "Item". Hope I can fix this, keep in mind I am new to c++ so please try to explain the solution or workaround simply, thanks.