Hi to all forum memberS! I would like to add something to the question of Mr Belli, about problems with vectorclass and STL container. This is my example : #include "vectorclass.h"
#include <iostream>
#include <vector> class myClass
{
private:
double g[4];
Vec4d av;
public:
myClass();
void prt();
}; myClass::myClass()
{
double f[4]={1,2,3,4};
av.load(f);
std::cout<<av.extract(0)<<std::endl; //THIS CALL IN THE CONSTRUCTOR DOESN'T CAUSE ANY PROBLEM
} void myClass::prt()
{
std::cout<<av.extract(0)<<std::endl; //THE SAME CALL HERE CAUSES THE PROGRAM TO CRASH
}
int main()
{
std::vector<myClass> aset;
aset.push_back(myClass());
aset.push_back(myClass());
aset[0].prt(); //CALL prt() AND... CRASH!
return(0);
}
this code, compiled with GCC on windows crashes as member function prt() is called. Note that : 1. the same call inside the constructor does not cause the crash..why??
2. if the member double g[4] is removed from myClass, the problem disappears;
3. if the std::vector has just one entry the problem disappears,
4. the same code compiled with GCC in Linux works without crashing ... As I'm not a professional programmer I cannot understand what is happening, I hope someone of you can have some idea about it. Finally, let me say thank you Mr Agner for such a good piece of code! Renato |