I have a base class name Elec, and 3 derived class.....capacitor, resistor, and series_circuits. I also used composition on class series_circuit to use capacitor and resistor object. In series circuit, i have declare an elec pointer to object.....Elec* *component. in the implementation, somewhere i wrote down component=new Elec*[10];..in another method, i write component= new Resistor(resName,resValue);....I got an error doing tht. They saying, unable to allocate an object of abstract type"REsistor" Can somebody have an idea to how to solve this issue??

From the error description I think the Elec class contains one or more pure virtual functions. If that is true then you can only allocate derived classes.

>>Can somebody have an idea to how to solve this issue??
allocate componment to be one of the derived classes.

i do have two pure functions in class Elec but like i said, class resistance is derived from class elec, so i would expect to be able to allocate the memory

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.