G
Grizlyk
Hello.
I am thinking: why if i will comment lines marked with '#' in the following
example, all will be compiled, else will not:
// ***********************
typedef unsigned uint;
namespace Pxx{
template <
class Tobj,
class c_Second,
class Tuint=uint
{
public:
typedef c_Second Second;
typedef typename c_Second::Third Third; //#1
typedef typename c_Second::Forth Forth; //#2
First(){}
inline explicit First(const Tuint);
public:
class Tfriend
{
public:
public:
mutable First *parent;
void
operator= (const First *const p)const
{ parent=const_cast<First*>(p); }
Tfriend()arent(0){}
Tfriend(const First& p):
parent(const_cast<First*>(&p))
{}
};
};}
// ***********************
namespace Pxx{
template <
class Tobj,
class c_First,
class c_Forth,
class c_Third,
class Tuint=uint
{
public:
typedef c_First First;
typedef c_Forth Forth;
typedef c_Third Third;
//derived Second
typedef typename c_First::Second c_Second;
Second(){}
inline Second(const First&);
};}
// ***********************
// ***********************
namespace Pxx{
namespace Puser{
// ***********************
template <class Tobj,class Tuint> class First;
template <class Tobj,class Tuint> class Second;
template <class Tobj,class Tuint> class Third;
template <class Tobj,class Tuint> class Forth;
// ***********************
template <
class Tobj,
class Tuint=uint
public Pxx::First<
Tobj,
typedef Pxx::First<
Tobj,
public:
typedef typename Tparent::Second Second;
First(){}
explicit First(const Tuint p):Tparent(p){}
};
// ***********************
template <
class Tobj,
class Tuint=uint
public Pxx::Second<
Tobj,
First<Tobj,Tuint>,
Forth<Tobj,Tuint>,
typedef Pxx::Second<
Tobj,
First<Tobj,Tuint>,
Forth<Tobj,Tuint>,
public:
typedef typename Tparent::First First;
Second(){}
Second(const First& p):Tparent(p){}
};
//namespace Puser
}
//namespace Pxx
}
using Pxx:user::First;
using Pxx:user::Second;
// ***********************
// ***********************
First<int> first(100);
Second<int> second(first);
=============
Output
11.cpp: In instantiation of
'Pxx::Second<int,
Pxx:user::First<int, unsigned int>,
Pxx:user::Forth<int, unsigned int>,
Pxx:user::Third<int, unsigned int>,
unsigned int>':
11.cpp:113: instantiated from
'Pxx:user::Second<int, unsigned int>'
11.cpp:14: instantiated from
'Pxx::First<int,
Pxx:user::Second<int, unsigned int>,
unsigned int>'
11.cpp:86: instantiated from
'Pxx:user::First<int, unsigned int>'
11.cpp:141: instantiated from here
11.cpp:57: error: no type named 'Second' in 'class
11.cpp:57: error: Pxx:user::First<int, unsigned int>'
--
Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new
"In thi world of fairy tales rolls are liked olso"
/Gnume/
I am thinking: why if i will comment lines marked with '#' in the following
example, all will be compiled, else will not:
// ***********************
typedef unsigned uint;
namespace Pxx{
template <
class Tobj,
class c_Second,
class Tuint=uint
class First
{
public:
typedef c_Second Second;
typedef typename c_Second::Third Third; //#1
typedef typename c_Second::Forth Forth; //#2
First(){}
inline explicit First(const Tuint);
public:
class Tfriend
{
public:
public:
mutable First *parent;
void
operator= (const First *const p)const
{ parent=const_cast<First*>(p); }
Tfriend()arent(0){}
Tfriend(const First& p):
parent(const_cast<First*>(&p))
{}
};
};}
// ***********************
namespace Pxx{
template <
class Tobj,
class c_First,
class c_Forth,
class c_Third,
class Tuint=uint
class Second
{
public:
typedef c_First First;
typedef c_Forth Forth;
typedef c_Third Third;
//derived Second
typedef typename c_First::Second c_Second;
Second(){}
inline Second(const First&);
};}
// ***********************
// ***********************
namespace Pxx{
namespace Puser{
// ***********************
template <class Tobj,class Tuint> class First;
template <class Tobj,class Tuint> class Second;
template <class Tobj,class Tuint> class Third;
template <class Tobj,class Tuint> class Forth;
// ***********************
template <
class Tobj,
class Tuint=uint
class First:
public Pxx::First<
Tobj,
{Second said:
typedef Pxx::First<
Tobj,
Tparent;Second said:
public:
typedef typename Tparent::Second Second;
First(){}
explicit First(const Tuint p):Tparent(p){}
};
// ***********************
template <
class Tobj,
class Tuint=uint
class Second:
public Pxx::Second<
Tobj,
First<Tobj,Tuint>,
Forth<Tobj,Tuint>,
{Third said:
typedef Pxx::Second<
Tobj,
First<Tobj,Tuint>,
Forth<Tobj,Tuint>,
Tparent;Third said:
public:
typedef typename Tparent::First First;
Second(){}
Second(const First& p):Tparent(p){}
};
//namespace Puser
}
//namespace Pxx
}
using Pxx:user::First;
using Pxx:user::Second;
// ***********************
// ***********************
First<int> first(100);
Second<int> second(first);
=============
Output
11.cpp: In instantiation of
'Pxx::Second<int,
Pxx:user::First<int, unsigned int>,
Pxx:user::Forth<int, unsigned int>,
Pxx:user::Third<int, unsigned int>,
unsigned int>':
11.cpp:113: instantiated from
'Pxx:user::Second<int, unsigned int>'
11.cpp:14: instantiated from
'Pxx::First<int,
Pxx:user::Second<int, unsigned int>,
unsigned int>'
11.cpp:86: instantiated from
'Pxx:user::First<int, unsigned int>'
11.cpp:141: instantiated from here
11.cpp:57: error: no type named 'Second' in 'class
11.cpp:57: error: Pxx:user::First<int, unsigned int>'
--
Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new
"In thi world of fairy tales rolls are liked olso"
/Gnume/