use of STL container list<class A> inside as a member of class B and destruction of class B object

Hi all...
I Have 2 questions.
1. Does STL containers have their default destructors. Are they called by default to destroy the container when that container goes out of scope?
2. I have two classes: class Telescope and class Panel. (in reality panels correspond to mirrors that are placed on large telescope reflector). A class telescope contains list<Panel> tel_pans. My question is When a Telescope object (let us say T) instantiated in main() goes out of scope does (compiler) default Telescope destructor automatically destroys the list<Panel>tel_pans ? Or free store memory allocated by list will stay floating even after destruction of T ??...
please help...
Attaching the header file of declarations to give better idea.

#ifndef RAY_TRACING_HEADER_LOADED
#define RAY_TRACING_HEADER_LOADED
//... all necessary include statements ...//

using namespace std;

const double DEPS=1.0e-14;
const double FEPS=1.0e-6;
// A base class that defines some basic functionality
class GeomOps {

public :
... 1st function
....nth function
virtual void display()=0 // Making this class as abstract base class
};

class Panel: public GeomOps
{
private:
// ... data members related to single panel

public:
[i]//constructors of panel class and function to modify data members of panel
// values of data have to be read from a file containing info abt all panels
[/i]
void SetPaneldata(int i,double k, double x, double y,double z, double roc, double f);

Panel(int i,double k, double x, double y,double z, double roc, double f);

Panel();

TVector3 Normal(double x,double y , double z);

inline double GetCX() { return XC; }

inline double GetCY() {return YC;}

inline double GetCZ() {return ZC;}

inline int GetPN() {return panel_i;}

void display();

void display(const char* tel_logfile);
};

class Telescope: public GeomOps
{
private:
int N_PAN;
const char* Tel_file ;
double ROC;
double kappa;
double fl;
double telC;
double phi;
double theta;
double XB,YB,ZB;
double dia;
double h;
double panx,pany;
double XMIN,YMIN,XMAX,YMAX;
bool Tess;
// Panel tel_pans;
list <Panel> tel_pans; // this is the part which is troublesome..
public:
// Telescope(const char *telfile);

Telescope(char *telfile);

int BASKET_CATCH(double CCX , double CCY , double CCZ , TVector3 V1 );

int BASKET_INTERSECTION(double *BX, double *BY, double *BZ, double CCX, double CCY, double CCZ, TVector3 Photon);

int IDENTIFY_PANEL(double x, double y);

void display();

void SetPhiTheta(double p, double t);

TVector3 Normal(double x, double y, double z);

int Reflection(double *rflx, double *rfly, double *rflz, double inc_cx, double inc_cy, double inc_cz,TVector3 inc_cray);

double findz(double x, double y);

double spot_size(double angle,unsigned int seed1, unsigned int seed2 = 4357);

inline void SetMonolithic() {Tess = false;}
};

#endif
Last edited on
1. Yes. All the standard containers have destructors that is called when it goes out of scope.

2. The list will be automatically destroyed.
Okk... thanks...
Topic archived. No new replies allowed.