OK, thanks a lot Philippe and Brett. That sorts out my problem. However, I
think I've uncovered a compatibility problem with KCC on linux.
I made a small class called randomclass - here is the code:
------- In randomclass.hpp -------
class randomclass : public TObject{
private:
int randomvariable;
public:
randomclass();
~randomclass();
ClassDef(randomclass,0)
};
-------- In randomclass.cpp ------
ClassImp(randomclass)
randomclass::randomclass(){
if (randomvariable){
cout << "randomclass constructor:" << endl;
cout << "randomvariable = " << randomvariable << endl;
}
randomvariable = 0;
}
randomclass::~randomclass(){
randomvariable = 5;
cout << "randomclass destructor:" << endl;
cout << "randomvariable = " << randomvariable << endl;
}
I made a small program, here is the code:
int main(int argc, char **argv){
randomclass *random;
random = new randomclass();
delete random;
random = new randomclass();
return 0;
}
When I build this program with g++ and run it, I get the
(expected) output:
randomclass destructor:
randomvariable = 5
However, when I build it with KCC and run it, I get the
(unexpected) output:
randomclass destructor:
randomvariable = 5
randomclass constructor:
randomvariable = 5
!!!!! randomvariable seems to have 'survived' the delete and new
statements!!!!!!
If anyone has made it this far, is not asleep and wishes to reproduce my
results then I have included the files with this e-mail. Just save
everything in a test directory, in Makefile set THISFILENAME (on line
18) to either 'linuxkcc' for KCC or 'linux' for g++ compilation, then type
'make'.
This will make an executable called messingaround which (should!) give the
above results,
cheers,
Simon
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:48 MET