A
abhisheksaksena1
I have following code:-
template<class T>
struct type
{
typedef T X;
type ():first(T()){}
T first; // the first stored value
};
struct coordinate
{
coordinate(unsigned i, unsigned j):x(i), y(j){}
unsigned x,y;
};
int main ()
{
type<coordinate *> p;
coordinate *third= p.first; //<---pointer third is initialized to
zero
}
How come here p.first is initialized to zero?
What T() for pointer means while initializing first? Does operator ()
defined for pointers?
Thanks
AS
template<class T>
struct type
{
typedef T X;
type ():first(T()){}
T first; // the first stored value
};
struct coordinate
{
coordinate(unsigned i, unsigned j):x(i), y(j){}
unsigned x,y;
};
int main ()
{
type<coordinate *> p;
coordinate *third= p.first; //<---pointer third is initialized to
zero
}
How come here p.first is initialized to zero?
What T() for pointer means while initializing first? Does operator ()
defined for pointers?
Thanks
AS