C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What would this defintion mean: int Function(class CString f

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Sep 26, 2006 9:10 am    Post subject: What would this defintion mean: int Function(class CString f Reply with quote



Just curious, any one know what the 3 part parameter "class CString
filename" would mean.

The code:
int TestFunc(class CString filename)
{
fopen(filename, "w");
}

Compile using Visaul C++, there is no complain about the defintion. But
the following error:

error C2664: 'fopen' : cannot convert parameter 1 from 'CString' to
'const char *'
Source or target has incomplete type


I know if I remove "class" in parameter list, the function just compile
fine. But what would it mean if I keep "class" there?

Any hint?
Back to top
Greg
Guest





PostPosted: Tue Sep 26, 2006 9:10 am    Post subject: Re: What would this defintion mean: int Function(class CStri Reply with quote



huguogang (AT) gmail (DOT) com wrote:
Quote:
Just curious, any one know what the 3 part parameter "class CString
filename" would mean.

The code:
int TestFunc(class CString filename)
{
fopen(filename, "w");
}

It means that "CString" is the name of a class - the class of the
"filename" parameter that is passed by value to the implementation of
the function TestFunc().

Quote:
Compile using Visaul C++, there is no complain about the defintion. But
the following error:

error C2664: 'fopen' : cannot convert parameter 1 from 'CString' to
'const char *'
Source or target has incomplete type


I know if I remove "class" in parameter list, the function just compile
fine. But what would it mean if I keep "class" there?

Are you sure that removing the keyword "class" fixes the compiler
error? It's not impossible, but it would have to mean that "CString" is
not in fact the name of a class as the parameter declaration claims.
Instead CString would have to be the name of a typedef.

Now the error that the compiler reports is it cannot find the
definition of the class CString. And the compiler must have CString's
class definition because filename, a CString parameter, is being passed
by value to TestFunc.

So the upshot is that either the keyword "class" as it is being used
here is either being completely unnecessary or it is being entirely
unhelpful.

Greg
Back to top
Guest






PostPosted: Mon Oct 02, 2006 9:10 am    Post subject: Re: What would this defintion mean: int Function(class CStri Reply with quote



The code is from an old project I am trying to port to VC7.1. Obviously
VC6.0 has no problem with the grammer.

In another similar place. I got a compiler error complaining about
undefined class CString.

This probably has something to do with the change of CString from a
real class definition to a typedef in VC7.1.


Greg wrote:
Quote:
huguogang (AT) gmail (DOT) com wrote:
Just curious, any one know what the 3 part parameter "class CString
filename" would mean.

The code:
int TestFunc(class CString filename)
{
fopen(filename, "w");
}

It means that "CString" is the name of a class - the class of the
"filename" parameter that is passed by value to the implementation of
the function TestFunc().

Compile using Visaul C++, there is no complain about the defintion. But
the following error:

error C2664: 'fopen' : cannot convert parameter 1 from 'CString' to
'const char *'
Source or target has incomplete type


I know if I remove "class" in parameter list, the function just compile
fine. But what would it mean if I keep "class" there?

Are you sure that removing the keyword "class" fixes the compiler
error? It's not impossible, but it would have to mean that "CString" is
not in fact the name of a class as the parameter declaration claims.
Instead CString would have to be the name of a typedef.

Now the error that the compiler reports is it cannot find the
definition of the class CString. And the compiler must have CString's
class definition because filename, a CString parameter, is being passed
by value to TestFunc.

So the upshot is that either the keyword "class" as it is being used
here is either being completely unnecessary or it is being entirely
unhelpful.

Greg
Back to top
Jim Langston
Guest





PostPosted: Mon Oct 02, 2006 9:10 am    Post subject: Re: What would this defintion mean: int Function(class CStri Reply with quote

I think it probably has something to do with the fact that VC 6.0 is
notorious for not following the current standard. 7.1 much closly follows
the standard.

<huguogang (AT) gmail (DOT) com> wrote in message
news:1159769372.250011.247870 (AT) e3g2000cwe (DOT) googlegroups.com...
Quote:
The code is from an old project I am trying to port to VC7.1. Obviously
VC6.0 has no problem with the grammer.

In another similar place. I got a compiler error complaining about
undefined class CString.

This probably has something to do with the change of CString from a
real class definition to a typedef in VC7.1.


Greg wrote:
huguogang (AT) gmail (DOT) com wrote:
Just curious, any one know what the 3 part parameter "class CString
filename" would mean.

The code:
int TestFunc(class CString filename)
{
fopen(filename, "w");
}

It means that "CString" is the name of a class - the class of the
"filename" parameter that is passed by value to the implementation of
the function TestFunc().

Compile using Visaul C++, there is no complain about the defintion. But
the following error:

error C2664: 'fopen' : cannot convert parameter 1 from 'CString' to
'const char *'
Source or target has incomplete type


I know if I remove "class" in parameter list, the function just compile
fine. But what would it mean if I keep "class" there?

Are you sure that removing the keyword "class" fixes the compiler
error? It's not impossible, but it would have to mean that "CString" is
not in fact the name of a class as the parameter declaration claims.
Instead CString would have to be the name of a typedef.

Now the error that the compiler reports is it cannot find the
definition of the class CString. And the compiler must have CString's
class definition because filename, a CString parameter, is being passed
by value to TestFunc.

So the upshot is that either the keyword "class" as it is being used
here is either being completely unnecessary or it is being entirely
unhelpful.

Greg
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.