468,458 Members | 1,739 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

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

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?

Sep 26 '06 #1
4 4401
hu*******@gmail.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

Sep 26 '06 #2

hu*******@gmail.com 写道:
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

Sep 26 '06 #3
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:
hu*******@gmail.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
Oct 2 '06 #4
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.

<hu*******@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro 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:
>hu*******@gmail.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

Oct 2 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Ben Amada | last post: by
3 posts views Thread by Ron | last post: by
3 posts views Thread by antred | last post: by
4 posts views Thread by desktop | last post: by
4 posts views Thread by Gilbert Tordeur | last post: by
16 posts views Thread by John Doe | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.