VC++ 5.0 vs 4.2 - New Error 
Author Message
 VC++ 5.0 vs 4.2 - New Error

See single line insertion below.

VC4 was allowing some illegal constructs due to
its late processing of template definitions.
--
-- Larry Brasfield
The aforementioned views are mine alone.


Quote:
> The following program fragment demonstrates a construct that we are using
> in a larger program.  Under VC++ 4.2, this compiles just fine.  Under VC++
> 5.0, however, I get several errors.  If this was a non-template class, I
> could resolve everything by inserting "class DEFG;" as the first line of
> the program.  But this is a template and I can't do it.  Does anyone have
> any ideas? Thanks in advance.

> Gary

> *** BEGIN PROGRAM FRAGEMENT ***

template <typename T> class DEFG;  // forward declare templated class
Quote:
> template <class T>
> class ABCD
> {
>    class DEFG<T> * q;  // VC++ 5.0 errors on this line, but 4.2 is OK
> };

> template <class S>
> class DEFG
> {
>    friend class ABCD<S>;
> };

> int WinMain(long hInstance, long hPrevInstance, char * lpCmdLine, int
> nCmdShow)
> {
>    return 0;
> }



Tue, 31 Aug 1999 03:00:00 GMT  
 VC++ 5.0 vs 4.2 - New Error

Quote:

> The following program fragment demonstrates a construct that we are using
> in a larger program.  Under VC++ 4.2, this compiles just fine.  Under VC++
> 5.0, however, I get several errors.  If this was a non-template class, I
> could resolve everything by inserting "class DEFG;" as the first line of
> the program.  But this is a template and I can't do it.  Does anyone have
> any ideas? Thanks in advance.

> Gary

> *** BEGIN PROGRAM FRAGEMENT ***

> template <class T>
> class ABCD
> {
>         class DEFG<T> * q;  // VC++ 5.0 errors on this line, but 4.2 is OK
> };

> template <class S>
> class DEFG
> {
>         friend class ABCD<S>;
> };

> int WinMain(long hInstance, long hPrevInstance, char * lpCmdLine, int
> nCmdShow)
> {
>         return 0;
> }

> *** END PROGRAM FRAGEMENT ***

> --
> Jesus Christ is Lord!

> PO Box 9573                     | Programming & Technical Services
> Glendale CA 91226-0573          | PGP Key ID: 0x1A0D44BD
> When cryptography is outlawed, bayl bhgynjf jvyy unir pelcgbtencul.
> Use of the return address on this message for commercial purposes is
> prohibited.  The transmission of unsolicited commercial material is
> prohibited under federal laws (47 USC 227).  Civil penalties and claims
> of $500.00 per occurrence (47 USC 227[c]) may be assessed for violations.

DEFG must be forward defined before ABCD:

template <class T> DEFG;

Esa



Tue, 31 Aug 1999 03:00:00 GMT  
 VC++ 5.0 vs 4.2 - New Error

Quote:


> > The following program fragment demonstrates a construct that we are using
> > in a larger program.  Under VC++ 4.2, this compiles just fine.  Under VC++
> > 5.0, however, I get several errors.  If this was a non-template class, I
> > could resolve everything by inserting "class DEFG;" as the first line of
> > the program.  But this is a template and I can't do it.  Does anyone have
> > any ideas? Thanks in advance.

> > Gary

> > *** BEGIN PROGRAM FRAGEMENT ***

> > template <class T>
> > class ABCD
> > {
> >         class DEFG<T> * q;  // VC++ 5.0 errors on this line, but 4.2 is OK
> > };

> > template <class S>
> > class DEFG
> > {
> >         friend class ABCD<S>;
> > };

> > int WinMain(long hInstance, long hPrevInstance, char * lpCmdLine, int
> > nCmdShow)
> > {
> >         return 0;
> > }

> > *** END PROGRAM FRAGEMENT ***

> > --
> > Jesus Christ is Lord!

> > PO Box 9573                     | Programming & Technical Services
> > Glendale CA 91226-0573          | PGP Key ID: 0x1A0D44BD
> > When cryptography is outlawed, bayl bhgynjf jvyy unir pelcgbtencul.
> > Use of the return address on this message for commercial purposes is
> > prohibited.  The transmission of unsolicited commercial material is
> > prohibited under federal laws (47 USC 227).  Civil penalties and claims
> > of $500.00 per occurrence (47 USC 227[c]) may be assessed for violations.

> DEFG must be forward defined before ABCD:

> template <class T> DEFG;

> Esa

Sorry for the syntax error, should be:

template <class T> class DEFG;



Tue, 31 Aug 1999 03:00:00 GMT  
 VC++ 5.0 vs 4.2 - New Error

Quote:

> The following program fragment demonstrates a construct that we are using
> in a larger program.  Under VC++ 4.2, this compiles just fine.  Under VC++
> 5.0, however, I get several errors.  If this was a non-template class, I
> could resolve everything by inserting "class DEFG;" as the first line of
> the program.  But this is a template and I can't do it.  Does anyone have
> any ideas? Thanks in advance.
> template <class T>
> class ABCD
> {
>         class DEFG<T> * q;  // VC++ 5.0 errors on this line, but 4.2 is OK
> };

> template <class S>
> class DEFG
> {
>         friend class ABCD<S>;
> };

<remainder of example snipped to leave room for spam>

VC++ 5.0 correctly requires you forward declare your class. The fact
that it is a template does not matter. Insert

        template< class S > class DEFG;

as the first line of the program.

        Phlip
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  --  All sensors report Patti having a very good time  --



Wed, 01 Sep 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. VC 5.0 Compile Errors (compiles fine with 4.2)

2. Problems debugging MFC under VC 4.2 with separate VC 5.0 installation present

3. VC++ 4.2 and VC++ 5.0 DLL

4. VC++ 5.0 API and VC++ 4.2

5. VC++ 4.2 and VC++ 5.0 DLL's

6. Converting from VC 4.2 to VC 5.0

7. VC++ 4.2 projects converted to VC++ 5.0

8. Visual C++ 5.0 -vs- 4.2

9. 4.2 vs. 5.0 - Microsoft party line

10. ++ operator: 4.2 vs 5.0

11. *** Visual C++ 4.2, 5.0, ActiveX VS Java?? ***

12. VC 4.2 link error linking static libraries from VC 6.0

 

 
Powered by phpBB® Forum Software