AnsweredAssumed Answered

MPC5748G C++ startup code

Question asked by Kfir Ben shimon on Jun 20, 2017
Latest reply on Jun 26, 2017 by Martin Kovar

Hi,

 

I have C++ code that contains Classes with inheritance.

For some reason upon a call to a virtual function the app crashes.

 

From what I understand there is a problem in the startup code that doesn't call the constructors and destructors.

 

example:

class ClassA
{
public:
virtual int sum() = 0;
};

Inherited Class:

class ClassB
{
public:
ClassB(int startValue);

int sum();

private:
int fStartValue;
};

 

Calls in main:

ClassA* pObjectA;
ClassB objectB(10);

 

main() {

pObjectA = &objectB;

total += pObjectA->sum();

}

 

The exception happens upon the call to sum.

 

Can anyone help me resolve this issue?

Outcomes