vector<BaseClass*> - how to put ChildClass objects in

Hello,

I have a base class A and the derived classes A_n (where n=1,…,N) . The base class, A, is inherited from TNamed class and dictionaries for it and for all A_n classes are created. Then a shared library, libA.so, is created for all of these base and derived classes. After all I am trying to do the following in my test.C macro :

void test() {
gSystem->Load(“libA.so”);
vector<A*> avec;
A_1* a1 = new A_1();
avec.push_back(a1);
}

When executing test.C it fails and says that (just a part of the error message),
Error: Can’t call vector<A*,allocator<A*> >::push_back(a1) …

If I replace “vector<A*> avec;” with “vector<A_1*> avec;” in the above method then it works.

My question is whether is there some way to make it also working but leaving the base class A in the vector implementation?
Many thanks in advance.

Best regards,
Gia

Hi,

you also need to create the dictionary for vector<A*>, vector<A_1*>,… Do you?

Cheers, Axel.

[quote=“Axel”]Hi,

you also need to create the dictionary for vector<A*>, vector<A_1*>,… Do you?

Cheers, Axel.[/quote]

Hello,

Yes, I do.
Anyway, I found that the problem was caused by another reason. I’ve 5.24.00 version installed and I’ve recently installed a new 5.25.02 release on the different location. But it seems it re-wrote the old /etc/root/sys.rootrc file. And this was fatal in my case because the package where lives the base A - class was linking to the new ROOT libs. The package where the A_n - classes live has its own .rootrc, which forces a dynamic path of the old ROOT libs. This mismatching between the libs was causing the problem.

Thanks and sorry for the noise.

Cheers, Gia