class Base1
{
private:
int testInput;
public:
Base1();
virtual int GetRow(void) = 0;
};
Base1::Base1()
{
testInput = 0;
}
class table : public Base1
{
private:
int row;
public:
table();
virtual int GetRow(void);
};
table::table()
{
//Contructor
row = 5;
}
int table::GetRow()
{
return row;
}
int main ()
{
Base1* pBase = new table[3];
pBase[0].GetRow();
pBase[1].GetRow(); //when i get to this line, the compiler keep saying access
// violation.
pBase[2].GetRow();
return 0;
}
I'm trying to create an array of 3 table class. The requirement is I have to use Base object to do that.
Base1 * pBase = new table[3];
look fine to me. But when I tried to access each table, the compiler said it's access violation. I don't know what wrong with this code. I'm using Visual Studio 2010 though.