473,245 Members | 1,790 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,245 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 1398

"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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.