I use smart pointer from Boost library. Suppose I have this object:
boost::shared_ptr<A> a(new A);
a->fileName = "/temp";
In the class B, I have:
bool open(A *a);
and
private: boost::shared_ptr<A> myA;
Then I declare an object B:
boost::shared_ptr<B> b(new B());
b->open(a.get());
bool B::open(A *a)
{
*B::myA = *a;
}
Those demonstration above is about pass by value parameter. Compiling is fine but when I run it, it gave this error:
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:412: typename boost::detail::shared_ptr_traits<T>::reference boost::shared_ptr<T>::operator*() const [with T = NameSpaceABC::Common::A]: Assertion `px != 0' failed.
Aborted
And for the same question above, what should I change to have: pass by reference parameters? As I am a C# and Java programmer, I just have switched to C++ for a quick project. I am not familiar with using pointers and Boost Smart pointer.
Thanks in advance and I am very appreciated about your help!