A
Arne Claus
Hi
I've got a little question about the following construct:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
class a {
public:
a() {
m_number =NULL;
}
~a() {
delete m_number;
}
setMember(int *myInt) {
m_number = myInt;
}
protected:
int* m_number;
};
// somwhere else in the code
a test;
a.setMember(new int(5));
test = a(); // memory leak?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
does this last line call a destructor on the original test, thus
destroying m_number correctly, or do I produce a memoryleak here? My
guess would be no, but I'm not entirely sure about that.
Arne
I've got a little question about the following construct:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
class a {
public:
a() {
m_number =NULL;
}
~a() {
delete m_number;
}
setMember(int *myInt) {
m_number = myInt;
}
protected:
int* m_number;
};
// somwhere else in the code
a test;
a.setMember(new int(5));
test = a(); // memory leak?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
does this last line call a destructor on the original test, thus
destroying m_number correctly, or do I produce a memoryleak here? My
guess would be no, but I'm not entirely sure about that.
Arne