0

I don't know why it's not working, i can compile:

g++ -I ~/local/include -L ~/local/lib -o tryBin ObjContainer.cpp -ldracodec -ldracoenc -lboost_serialization -lboost_system 

but when execute i get the following error.

Segmentation fault (core dumped)

main:

int main() {
    ObjContainer objCon;
    return 0;}



  ObjContainer::ObjContainer() {

        file_streamer_ = NULL;
        oa_ = NULL;
    }

    ObjContainer::~ObjContainer() {
        delete file_streamer_;
        delete file_streamer_in_;
        delete oa_;

    }

and my headerFile:

 class ObjContainer {
    public:

        ObjContainer();
        virtual ~ObjContainer();
    };
badcode
  • 581
  • 1
  • 9
  • 28
  • 3
    (1) Code will not compile, please post a [mcve]. (2) Probably `file_streamer_in_` is non-NULL (uninitialised) – Richard Critten Jun 11 '20 at 12:35
  • 1
    Does this answer your question? [What is a segmentation fault?](https://stackoverflow.com/questions/2346806/what-is-a-segmentation-fault) – Alberto Sinigaglia Jun 11 '20 at 12:35
  • The destructor is deleting a bunch of pointers. Were they properly allocated? Sometimes it is useful to check if a pointer is not null before deleting it. – DarioP Jun 11 '20 at 12:39
  • 1
    @DarioP deleting _null_ is ok – Richard Critten Jun 11 '20 at 12:39
  • @RichardCritten thank you Richard when i add file_streamer_in_ = NULL; problem is solved. sorry, im newbie with c++, i can delete question or if you give a answer i can accept it. – badcode Jun 11 '20 at 13:27

0 Answers0