Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > What would this defintion mean: int Function(class CString filename)

Reply
Thread Tools

What would this defintion mean: int Function(class CString filename)

 
 
huguogang@gmail.com
Guest
Posts: n/a
 
      09-26-2006
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?

 
Reply With Quote
 
 
 
 
Greg
Guest
Posts: n/a
 
      09-26-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
 
 
 
sods
Guest
Posts: n/a
 
      09-26-2006

(E-Mail Removed) 写道:

> 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?



have this kind of function definition?
I think it's grammar error.

-sods

 
Reply With Quote
 
huguogang@gmail.com
Guest
Posts: n/a
 
      10-02-2006
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:
> (E-Mail Removed) 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


 
Reply With Quote
 
Jim Langston
Guest
Posts: n/a
 
      10-02-2006
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.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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:
>> (E-Mail Removed) 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

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CString changing an independant int Rob Prins C++ 2 08-10-2008 11:02 PM
Different TD style defintion per table? Bardo HTML 3 07-11-2004 12:11 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
XSD document for XSD defintion Rick Razzano XML 1 09-26-2003 12:41 AM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments