473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Does the typename keyword make sense here?

Hello,

I've inherited a bunch of C++ code which was developed on Windows and
I'm in the process of trying to port it to Linux/g++. The following is
similar to one very small piece of the code:

//Begin test1.cpp
template<class B>
class CHB
{ };

template <typename B>

struct BCBT
{
typedef typename CHB<B> BCB;
};
//End test1.cpp

When I try to compile the above, g++ complains thusly:

test1.cpp:9 syntax error before ';' token.

Presumably, this code compiles under MS Visual Studio 7.1. If I remove
the 'typename' from line nine, it's compilable under g++. Two questions
then:

1) Is it legal. In other words, should g++ complain?
2) If it is legal, what does it do? It's not clear to me what purpose
typname would serve in this particular context.

Thanks!

-exits

Jul 22 '05 #1
1 1152

"Exits Funnel" <ex***************@yahoo.com> wrote in message
Hello,

When I try to compile the above, g++ complains thusly: [snip] test1.cpp:9 syntax error before ';' token.

Presumably, this code compiles under MS Visual Studio 7.1. If I remove
the 'typename' from line nine, it's compilable under g++. Two questions
then:

1) Is it legal. In other words, should g++ complain?
No, it isn't . g++ is correct.
2) If it is legal, what does it do? It's not clear to me what purpose
typname would serve in this particular context.


Sharad
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Alexander Malkis | last post by:
What's the semantical/syntactical difference between two keywords "class" and "typename" (apart from different spelling)? -- Best regards, Alex. PS. To email me, remove "loeschedies" from...
2
by: Anonymous | last post by:
I'm trying to port code from VC.net to VC.net 2003. Here's a typical piece of code that's often used: template<class T> class PseudoContainer { typedef T::iterator iterator; // this line will...
2
by: Chris Foster | last post by:
Hi, I'm having some difficulty using types which are defined in a base class inside a derived class. The problem crops up using template classes. The following test code encapsulates what I'd...
13
by: Staffan Langin | last post by:
Hello, In the following code-snippet, template<class Base> class Foo : public Base {
9
by: Kobe | last post by:
Is there any difference in: template <class T> vs. template <typename T> ?
6
by: 466 | last post by:
Hi all, I have this member in a template class: bool opsInsert(int nId, T pObj){ pairRet = insert(typename std::map<int,T>::value_type(nId, pObj)); } which does compile with gcc but not with...
7
by: StephQ | last post by:
First of all: distinction of keywords typename and class in template arguments. Accoarding to a post in a well known moderated group: "There are three possibilities for template arguments: 1)...
5
by: Jess | last post by:
Hello, I've seen two forms of template declarations template<typename T> class A{...}; and template<class T>
21
by: Ray Cassick | last post by:
I can't believe why I had not noticed this before and why I never asked it before... When defining a string why is it not required to use the new keyword? Like: Dim a As String = New String ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.