plz take a look at the following code
#include <iostream>
#include <string>
#include <iostream>
#include <string>
using namespace std;
class A
{
public:
string sa;
A(string sia);
};
class B:public A
{
public:
string sb;
B(string sia, string sib);
};
A::A(string sia):sa(sia)
{
}
B::B( string sia, string sib):A(sia),sb(sib)
{
}
int main(int argc, char*argv[])
{
string param1="abcd";
string param2="efgh";
A *b;
b = new B(param1, param2);
delete b;
return 0;
}
the thing is when compiling with gcc and running with valgrind i have a memory leak
the valgrind output regarding the leak is:
==12855== 17 bytes in 1 blocks are definitely lost in loss record 1 of 1
==12855== at 0x40232B4: operator new(unsigned) (vg_replace_malloc.c:224)
==12855== by 0x40D5FF0: std::string::_Rep::_S_create(unsigned, unsigned, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.9)
==12855== by 0x40D7334: (within /usr/lib/libstdc++.so.6.0.9)
==12855== by 0x40D74E6: std::string::string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.9)
==12855== by 0x8048B26: main (executable.cpp:11)
if someone could explain me the reason of the leak i would be very thankfull
thx