473,396 Members | 1,799 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,396 software developers and data experts.

Embedded class' or VC++7 compiler's problem ?

N4M
Dear,
I have codes as follows:
template<class T>
class A {
public: // embedded class
class E;
public: // types
typedef E TE;
public:// member functions
TE somefunc();
private: // member data
//----------------------------
// embedded class
public:
class E {
//.....//
};
};
//
template<class T>
A<T>::TE A<T>::somefunc() {....}

When I compile these codes with VC++.NET, there are error messages:

c:\DATA\C++\Common\list.h(389): error C2143: syntax error : missing
';' before 'list_base<TNValue>::insert'
c:\DATA\C++\Common\list.h(389): error C2501:
'list_base<TNValue>::iterator' : missing storage-class or type
specifiers

// TNValue = T, list_base = A, iterator = TE

The same codes are compilled without problem by VC++ 6.

How come?
Is there something not-so-good with my embedded class use? Do you
recommend embedded classes or have other better solutions?

Thansk for your time.
Nguyen Mai
P/S: The same post can be found at .moderated/
Jul 22 '05 #1
3 1404

"N4M" <dn******@yahoo.com> wrote in message
news:6e**************************@posting.google.c om...
Dear,
I have codes as follows:
template<class T>
class A {
public: // embedded class
class E;
public: // types
typedef E TE;
public:// member functions
TE somefunc();
private: // member data
//----------------------------
// embedded class
public:
class E {
//.....//
};
};
//
template<class T>
A<T>::TE A<T>::somefunc() {....}

When I compile these codes with VC++.NET, there are error messages:

c:\DATA\C++\Common\list.h(389): error C2143: syntax error : missing
';' before 'list_base<TNValue>::insert'
c:\DATA\C++\Common\list.h(389): error C2501:
'list_base<TNValue>::iterator' : missing storage-class or type
specifiers

// TNValue = T, list_base = A, iterator = TE


I don't see any "insert" anywhere there??? Perhaps you've snipped out the
relevant code?

Is there a reason you've substituted all the identifiers with these short
names?

Also, why are you using that typedef? You state at the bottom that TE is an
iterator, but your typedef says it's the same as E. I'm confused, to say
the least...

-Howard


Jul 22 '05 #2
N4M
"Howard" <al*****@hotmail.com> wrote in message news:<tm*********************@bgtnsc04-news.ops.worldnet.att.net>...
"N4M" <dn******@yahoo.com> wrote in message
news:6e**************************@posting.google.c om...
Dear,
I have codes as follows:
template<class T>
class A {
public: // embedded class
class E;
public: // types
typedef E TE;
public:// member functions
TE somefunc();
private: // member data
//----------------------------
// embedded class
public:
class E {
//.....//
};
};
//
template<class T>
A<T>::TE A<T>::somefunc() {....}

When I compile these codes with VC++.NET, there are error messages:

c:\DATA\C++\Common\list.h(389): error C2143: syntax error : missing
';' before 'list_base<TNValue>::insert'
c:\DATA\C++\Common\list.h(389): error C2501:
'list_base<TNValue>::iterator' : missing storage-class or type
specifiers

// TNValue = T, list_base = A, iterator = TE


I don't see any "insert" anywhere there??? Perhaps you've snipped out the
relevant code?

Is there a reason you've substituted all the identifiers with these short
names?

Also, why are you using that typedef? You state at the bottom that TE is an
iterator, but your typedef says it's the same as E. I'm confused, to say
the least...

-Howard


Thanks for your follow-up. The real code is somewhat lengthier, but
the main point is:
1- I use embedded classes (e.g. class E) and template for class A
2- some functions are defined as:
class A<T>::a type defined in A class A<T>::function declared in A()
{....}
//a function declared in A with a return type defined in A

Then VC++.NET gives errors, while VC++.6 compiles. That's strange
since VC++.NET is much more standard conformed (98% vs 86%). I have no
other compilers to check.
But I am unsure it is the good way to use embedded classes,
especiallly along with template.
Hope to receive your comments.
Nguyen Mai
Jul 22 '05 #3

"N4M" <dn******@yahoo.com> wrote in message
news:6e*************************@posting.google.co m...
"Howard" <al*****@hotmail.com> wrote in message
news:<tm*********************@bgtnsc04-news.ops.worldnet.att.net>...
"N4M" <dn******@yahoo.com> wrote in message
news:6e**************************@posting.google.c om...
> Dear,
> I have codes as follows:
> template<class T>
> class A {
> public: // embedded class
> class E;
> public: // types
> typedef E TE;
> public:// member functions
> TE somefunc();
> private: // member data
> //----------------------------
> // embedded class
> public:
> class E {
> //.....//
> };
> };
> //
> template<class T>
> A<T>::TE A<T>::somefunc() {....}
>
> When I compile these codes with VC++.NET, there are error messages:
>
> c:\DATA\C++\Common\list.h(389): error C2143: syntax error : missing
> ';' before 'list_base<TNValue>::insert'
> c:\DATA\C++\Common\list.h(389): error C2501:
> 'list_base<TNValue>::iterator' : missing storage-class or type
> specifiers
>
> // TNValue = T, list_base = A, iterator = TE
>


I don't see any "insert" anywhere there??? Perhaps you've snipped out
the
relevant code?

Is there a reason you've substituted all the identifiers with these short
names?

Also, why are you using that typedef? You state at the bottom that TE is
an
iterator, but your typedef says it's the same as E. I'm confused, to say
the least...

-Howard


Thanks for your follow-up. The real code is somewhat lengthier, but
the main point is:
1- I use embedded classes (e.g. class E) and template for class A
2- some functions are defined as:
class A<T>::a type defined in A class A<T>::function declared in A()
{....}
//a function declared in A with a return type defined in A

Then VC++.NET gives errors, while VC++.6 compiles. That's strange
since VC++.NET is much more standard conformed (98% vs 86%). I have no
other compilers to check.
But I am unsure it is the good way to use embedded classes,
especiallly along with template.
Hope to receive your comments.
Nguyen Mai


I don't know why people expect their code errors to be fixed when they don't
post the real code, or even compilable code.If your original code was too
lengthy then surely you could have posted a complete example that
illustrates the same problem?

In any case with one minor addition and a few lines added for completeness
your code compiles perfectly well on my copy of VC++ .NET

template<class T>
class A {
public: // embedded class
class E;
public: // types
typedef E TE;
public:// member functions
TE somefunc();
private: // member data
//----------------------------
// embedded class
public:
class E {
//.....//
};
};
//
template<class T>
typename A<T>::TE A<T>::somefunc()
{
return A<T>::TE();
}

int main()
{
A<int> x;
x.somefunc();
}

The minor addition was 'typename' which was missing from your somefunc()
definition.

If you want to check the correctness of your code then a good place to do so
is here http://www.comeaucomputing.com/tryitout/. This online compiler also
has no problem with your corrected code.

john
Jul 22 '05 #4

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

Similar topics

10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
3
by: Randy Kobes | last post by:
I have a couple of macros: #define QUOTE_ME_HELPER(foo) #foo #define QUOTE_ME(foo) QUOTE_ME_HELPER(foo) and was wanting to use them as, for example, const char bar =...
6
by: marco_segurini | last post by:
Hi, the following sample code shows a compiler error I get trying to build some old code with the last CL compiler (vers 13.10.3077): //----- begin #include <iostream> namespace ns {
3
by: Sven Groot | last post by:
This was posted by someone in comp.lang.c++, and later in microsoft.public.vstudio.general, but since I know Carl is in this group, and he's the one that should read this, I've reposted it here....
5
by: Felix I. Wyss | last post by:
Good Afternoon, I recently noticed that some very simple methods of a template declared and used in a DLL library get inlined when used by the DLL itself, but not by other DLLs and EXEs. After...
5
by: rich | last post by:
Hi there, I defined a class template (MyClass) and some member variables and functions, as following: template<class T1, class T2> class MyClass { ... struct m_variable
7
by: H. Williams | last post by:
I know the .Net Cursor class doesn't work with color cursors. So I'm currently using the LoadCursorFromFile API with reflection to set color cursors: here is my code: public static extern...
49
by: Alex Vinokur | last post by:
Are there any restrictions/problems for use of C++ STL in development in embedded systems? In particular: * Does STL require too much space/memory? * Is 'implementation of STL...
17
by: Fabry | last post by:
Hi All, I'm new of this group and I do not know if this is the correct group for my question. I have a DLL with its export library (.lib) wrote in Borland C++ 6. In borland everything is OK and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.