Consider two classes
class A{
public:
int i;
A(){}
explicit A(const int ii):i(ii){}
virtual ~A(){
cout<<"~A - "<< i <<endl;
}
virtual void inc(){
i++;
cout<<"i: "<<i<<endl;
}
};
class B: public A{
public:
int j;
B(){}
explicit B(const int jj, const int ii=-1):A(ii), j(jj){}
~B(){
cout<<"~B - "<<i<<", "<<j<<endl;
}
void inc(){
A::inc();
j++;
cout<<"j: "<<j<<endl;
}
};
Now we can do like this in main()
:
A *pa = new B();
//...
pa->inc(); // implements B::inc();
Now the version using boost
library
boost::shared_ptr<A> pa = boost::make_shared<B>(2);
//...
pa->inc(); // implements B::inc();
My question, in using the boost
version, is whether it's fine to use this way, i.e., both versions can be used in same manner, or do I need to do something extra (I don't know much internals of boost)