Member types used as function definition parameters

N

NagelBagel

typedef double type;

class A {
typedef int type;
void f(type);
};

void A::f(type)
{
}

int main() { }

I was wondering if this code was correct. It compiles correctly under
gcc, but by the standard, does the last usage of type need to be
qualified as A::type?

Thanks.
 
A

Alf P. Steinbach

* (e-mail address removed):
typedef double type;

class A {
typedef int type;
void f(type);
};

void A::f(type)
{
}

int main() { }

I was wondering if this code was correct. It compiles correctly under
gcc, but by the standard, does the last usage of type need to be
qualified as A::type?

No, it's OK. However the function result type needs to be qualified if
it refers to a type defined in the class. The 1998 C++ standard is a
bit unclear and inconsistent about this; it was corrected in C++ 2003.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top