Hello.
Why were base class "typedefs" hidden by template<and explicit usage
of them does not work too?
Try open only one of the lines in the example below
//using Tparent::Tptr;
//typedef Tparent::Tptr Tptr;
Consider example:
template< class A, class Bclass Z;
template< class A, class Bclass Ext1;
template< class A, class B>
class Base
{
public:
typedef Z<A,BTptr;
};
template< class A >
class Derived: public Base<A, Ext1<int,int
{
public:
typedef Base<A, Ext1<int,int Tparent;
using Tparent::Tptr;
typedef Tparent::Tptr Tptr;
inline void test(const Tptr obj)throw();
};
class Base2
{
public:
typedef Z<int,intTptr;
};
class Derived2: public Base2
{
public:
typedef Base2 Tparent;
using Tparent::Tptr;
//typedef Tparent::Tptr Tptr;
inline void test(const Tptr obj)throw();
};
/*
5.cpp:18: error: ISO C++ forbids declaration of 'Tptr' with no type
5.cpp:18: error: cannot declare member 'Base<A, Ext1<int, int::Tptr'
within 'Derived<A>'
5.cpp:18: error: expected ';' before 'Tptr'
5.cpp:20: error: expected ',' or '...' before 'obj'
5.cpp:20: error: ISO C++ forbids declaration of 'Tptr' with no type
*/ 4 2294
Grizlyk napsal:
Hello.
Why were base class "typedefs" hidden by template<and explicit usage
of them does not work too?
Try open only one of the lines in the example below
//using Tparent::Tptr;
//typedef Tparent::Tptr Tptr;
Consider example:
template< class A, class Bclass Z;
template< class A, class Bclass Ext1;
template< class A, class B>
class Base
{
public:
typedef Z<A,BTptr;
};
template< class A >
class Derived: public Base<A, Ext1<int,int
{
public:
typedef Base<A, Ext1<int,int Tparent;
using Tparent::Tptr;
typedef Tparent::Tptr Tptr;
inline void test(const Tptr obj)throw();
};
class Base2
{
public:
typedef Z<int,intTptr;
};
class Derived2: public Base2
{
public:
typedef Base2 Tparent;
using Tparent::Tptr;
//typedef Tparent::Tptr Tptr;
inline void test(const Tptr obj)throw();
};
/*
5.cpp:18: error: ISO C++ forbids declaration of 'Tptr' with no type
5.cpp:18: error: cannot declare member 'Base<A, Ext1<int, int::Tptr'
within 'Derived<A>'
5.cpp:18: error: expected ';' before 'Tptr'
5.cpp:20: error: expected ',' or '...' before 'obj'
5.cpp:20: error: ISO C++ forbids declaration of 'Tptr' with no type
*/
There is missing keyword typedef:
template< class A, class Bclass Z;
template< class A, class Bclass Ext1;
template< class A, class B>
class Base
{
public:
typedef Z<A,BTptr;
};
template< class A >
class Derived: public Base<A, Ext1<int,int
{
public:
typedef Base<A, Ext1<int,int Tparent;
using Tparent::Tptr;
typedef typename Tparent::Tptr Tptr2;
inline void test(const Tptr2 obj)throw();
};
class Base2
{
public:
typedef Z<int,intTptr;
};
class Derived2: public Base2
{
public:
typedef Base2 Tparent;
using Tparent::Tptr;
//typedef Tparent::Tptr Tptr;
inline void test(const Tptr obj)throw();
};
int main()
{
}
Ondra Holub wrote:
There is missing keyword typedef:
Where exactly?
I want to say, that compiler can not compile even well defined (known)
type from base class.
Grizlyk napsal:
Ondra Holub wrote:
There is missing keyword typedef:
Where exactly?
I want to say, that compiler can not compile even well defined (known)
type from base class.
Oh, sorry. I made typo - there is missing typename (not typedef) in
typedef typename Tparent::Tptr Tptr2
Here is a touched part of code:
template< class A >
class Derived: public Base<A, Ext1<int,int
{
public:
typedef Base<A, Ext1<int,int Tparent;
using Tparent::Tptr;
typedef typename Tparent::Tptr Tptr2;
inline void test(const Tptr2 obj)throw();
};
Ondra Holub write:
Oh, sorry. I made typo - there is missing typename (not typedef) in
typedef typename Tparent::Tptr Tptr2
Here is a touched part of code:
template< class A >
class Derived: public Base<A, Ext1<int,int
{
public:
typedef Base<A, Ext1<int,int Tparent;
using Tparent::Tptr;
typedef typename Tparent::Tptr Tptr2;
inline void test(const Tptr2 obj)throw();
};
Yes, it is work. Thanks.
But it is very not clear to me, why I can declare with "using" method
of base class, but can not do type. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eshrath |
last post by:
Hi,
What I am trying to do:
=======================
I need to form a table in html using the xsl but the table that is
formed is quite long and cannot be viewed in our application. So we
are...
|
by: SoilMan |
last post by:
Consider the following:
class xyz
{
public:
template <typename T>
void foo(T x)
{
cout << "foo<T> " << x << endl;
}
|
by: Gary li |
last post by:
Hi, all
I find "template template" class cann't been compiled in VC6 but can ok
in Redhat9. I write a test program like as:
template< template<class> class T>
class A
{
};
int main()
{...
|
by: Nate Barney |
last post by:
I have:
// base class for Vector and Matrix
template <unsigned N,typename Value=float>
class NonScalar
{
public:
Value *ptr() { return e; }
const Value *ptr() const { return e; }
|
by: Grizlyk |
last post by:
Hello.
Returning to question of manual class type identification, tell me, for
ordinary inheritance is C++ garantee that
dynamic_cast<Derived*>(Base*)
can be implemented similarly to
...
|
by: George2 |
last post by:
Hello everyone,
I sometimes saw code with template<and followed by a class
definition, like,
template<class {
// class definition
|
by: jason.cipriani |
last post by:
Is there any difference between declaring a template parameter as a
"typename" or a "class"? E.g.
template <class TT f() { }
template <typename TT g() { }
Thanks,
Jason
|
by: jacek.dziedzic |
last post by:
Hi!
I need to be able to track memory usage in a medium-sized
application I'm developing. The only significant (memory-wise) non-
local objects are of two types -- std::vector<and of a custom...
|
by: Juha Nieminen |
last post by:
joseph cook wrote:
Not always. By default, yes, but you can specify other comparators, eg:
std::map<int, int, std::greaterreversedMap;
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |