So i'm doing this homework problem for my class and I keep getting the error (Cannot allocate an object of abstract type 'Bond') when I'm trying to create bond pointer.
Here is a snippet of how I start to create a new bond pointer.
1 2 3 4 5 6
if (first == "bond")
{
strm >> name >> year >> initialVal >> rate;
Bond* new_bond = new Bond(name, year, initialVal, rate);
cust.back()->add_asset(new_bond);
}
Hey,
I was just tinkering with your code and I found something that you may be interested in.
At line 9 of your base class Asset, I removed the const keyword and supplied a body of your function compute in class Bond. And voila!! I was able to create a new object of class Bond.
I don't know the reason behind this, but somehow I think that declaring a virtual function const must have something with this. Try my advice and let us know what happened.