Niner710 0 Light Poster

Hi ,

I am trying to use a Boost shared ptr with a map template. I have a bunch of subclasses that will be derived from class TestSuperClass. I will then used a shared_ptr to point to the class and will use a map template so that depending on the string that is entered it will point to the correct subclass of TestSuperClass.

Blah.h file
typedef boost::shared_ptr<TestSuperClass> TestClassPtr_t;
typedef std::map<std::string, TestClassPtr_t> TestClassMap_t;
extern TestClassMap_t gTests;
extern Tblk gTblk;
Blah.cpp
Tblk gTblk;
TestClassMap_t gTests;
//set from map
gTests["Iddq"] = TestClassPtr_t new TestSuperClass; ==> ERROR
//get from map
TestClassPtr_t myIddq = gTests["Iddq"];
myIddq->setGlobalFromProtected(); ==>ERROR

I have problem when I try to set my map as so.......

gTests["Iddq"] = TestClassPtr_t new TestSuperClass; ==>Error

I am trying to set the string "Iddq" to a boost shared pointer to subclass of TestSuperClass.

Also have a problem when I try to get from my map....

myIddq->setGlobalFromProtected(); ==>ERROR

Can anyone tell me what I am doing wrong with either two of these errors? Thanks!

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.