I have the following class:
(header)
struct udtMapping
{
int ByteStart;
int ByteCount;
int iHPUnitID;
};
class clsMapping : public CBaseStructure
{
private:
vector<udtMapping> m_content;
protected:
public:
vector<udtMapping> &Content();
void Add(int i1, int i2, int int3);
};
cpp file:
vector<udtMapping> &clsMapping::Content()
{
return m_content;
}
void clsMapping::Add(int i1, int i2,int i3)
{
udtMapping n;
n.ByteStart = i1;
n.ByteCount = i2;
n.iHPUnitID = i3;
m_content.push_back(n);
return;
}
Now I wanted to use this class by saying
clsMapping nMapping;
But the compiler tells me "Can not create instance from abstract class".
I am not sure where I went wrong. Thank you for the help.
Edit: On request here is the CBaseStructure
class CBaseStructure
{
protected:
virtual void ProcessTxtLine(string line) = 0;
virtual void AfterLoad();
virtual string CompactLine(string line);
public:
void Load(string file);
void Load2(string file);
void Load3(string file);
};
CBaseStructure must be an abstract class. If you want to derive from it and you want a non-abstract class then you must override each pure virtual function that CBaseStructure declares. Clearly you didn't do that.
EDIT
CBaseStructure has one pure virtual function ProcessTxtLine
. Your class must override that function.
There is nothing in your code that explains why you are inheriting from CBaseStructure, what do you thing it will do for you?