C++ constructor sets member but its still null?

  aspose-slides, c++, nullreferenceexception

I’m working with the Apose.Slides C++ library, using C++ 20 and g++ compiler / linker.

I have this class:

 class ChartDataCell : public AsposeObjectWrapper<IChartDataCell>, public Php::Base
            ChartDataCell(System::SharedPtr<IChartDataCell> cell) : AsposeObjectWrapper<IChartDataCell>(cell) {};
            void __construct(Php::Parameters &params);
            Php::Value get_Value();


This inherits from a template class and a normal class. I use this template class everywhere and it works fine.

As you can see, the parent constructor is called. It is supposed to set the value of a member to the value of its argument (cell).

Now, this compiles fine. But if I try to use the member I just initialised, I get null System::NullReferenceException exception.

So in C++ code:

Php::Value ChartDataCell::get_Value() {
    SharedPtr<System::Object> val = _asposeObj->get_Value();
    return val->ToString().ToUtf8String();    


Here, _asposeObj is the member whose value the constructor was supposed to set. But it’s a null reference. I can print its type using something like:

   cout << typeid(_asposeObj).name() << endl;

This prints the correct typename, but I still can’t call methods of this object. How is this possible?

Source: Windows Questions C++