Understandin Accessing protected member variables GCC
sonatabar bar
sonatabar@yahoo.com
Mon Feb 26 15:28:00 GMT 2007
Hi All,
I am trying to access a protected data member of a
base class, within the constructor of a publicly
derived class and results in "error: undefined first
use"
The way these files are included are as show below.
Can anyone please elaborate on this. Also to note is
that if I used the 'this' to dereference it, I can
overcome the error. But still want to understand why
it does so in the below setup.
Thanks for any help!
-sonata
F1.h:
-----
#include "Foo.h"
template<class T>
class ST {
protected:
int sTID;
public:
ST();
~ST();
int Sme(...);
};
#include "ST_A.h"
#include "ST_B.h"
#include "ST_C.h"
template<class T>
int ST<T>::Sme(...)
{ ... }
//========== End of F1.h
ST_A.h :
-------
#include <time.h>
#define sPID 3
template<class T>
class S_P: public ST<T> {
private:
public:
S_P() {sTID = sPID;} // <== Undefined for sTID?
this works if i use this->sTID I am trying to
understand why it doesn't otherwise
~S_P() {}
...
};
....
//End of ST_A.h
____________________________________________________________________________________
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/
More information about the Gcc-help
mailing list