Dynamic construction of an object

Hi all, I would like first to congratulate the admins of the forum for all the good work i see here and secondly to ask a question which maybe quite silly for you but you will have to forgive me as I am a structural engineer whom experience with C++ is quite recent. My question is on how to dynamically create an object of an abstract class. To be more specific:
When I have a NodalLoad class, I can construct dynamically the object by NodalLoad *theLoad = new NodalLoad(1, 4, theLoadValues);

NodalLoad::NodalLoad(int tag, int node, const Vector &theLoad, bool isLoadConstant)
:Load(tag, LOAD_TAG_NodalLoad),
myNode(node), myNodePtr(0), load(0), konstant(isLoadConstant)
{
load = new Vector(theLoad);

if (load == 0) {
opserr << "FATAL NodalLoad::NodalLoad(int node, const Vector &theLoad) -";
opserr << " ran out of memory for load on Node " << node << endln;
exit(-1);
}
// AddingSensitivity:BEGIN /////////////////////////////////////
parameterID = 0;
// AddingSensitivity:END ///////////////////////////////////////
}

The problem is when I want to construct that way an ElementalLoad object I can not because the class is abstract.

ElementalLoad::ElementalLoad(int tag, int cTag, int theEleTag)
:Load(tag, cTag), eleTag(theEleTag), theElement(0)
{

}

Do you have any suggestions on how to deal with that? Thank you in advance!
An abstract class cannot be instantiated in C++. You must first derive a class from that abstract class, imlement all abstract functions and then create an instance from that derived class.
Topic archived. No new replies allowed.