Hi,
The following piece of code
outputs this:
If I comment out the line where methodB is used, I get no B construction/destruction output.
What I desperately need to know is:
1) How can B be constructed before A?
2) Is this the reason behind the glibc error?
Thanks.
The following piece of code
Code:
#include <stdio.h>
class A
{
public:
A()
{
printf("A constructed\n");
}
~A()
{
printf("A destroyed\n");
}
void dummyMethod()
{
objectB.methodB(&objectC);
}
private:
B objectB;
C objectC;
};
int main(int argc, char *argv[])
{
A *ptA = new A;
use(A);
delete A;
return 0;
}
Code:
B constructed A constructed ... A destroyed B destroyed *** glibc detected *** ./capture: free(): invalid next size (fast): 0x0000000007fb3090 *** ...
What I desperately need to know is:
1) How can B be constructed before A?
2) Is this the reason behind the glibc error?
Thanks.
Comment