473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

enum and classes

How come that this is legal:

class A
{
enum Enum{B,C};
Enum foo()
{
return B;
}
};

But this isn't:

class A
{
enum Enum{B,C};
Enum foo();
};

Enum A::foo()
{
return B;
}

Apr 19 '07 #1
4 1447
Gaijinco wrote:
How come that this is legal:

class A
{
enum Enum{B,C};
Enum foo()
{
return B;
}
};

But this isn't:

class A
{
enum Enum{B,C};
Enum foo();
};

Enum A::foo()
{
return B;
}
If you define the function outside of the scope of A, the symbol Enum
doesn't mean anything anymore by itself. You have to write

A::Enum A::foo()
{
return B;
}
regards,

Zeppe
Apr 19 '07 #2
On Apr 19, 5:38 pm, zeppe <z...@nospam.remove.all.this.email.it>
wrote:
Gaijinco wrote:
How come that this is legal:
class A
{
enum Enum{B,C};
Enum foo()
{
return B;
}
};
But this isn't:
class A
{
enum Enum{B,C};
Enum foo();
};
Enum A::foo()
{
return B;
}

If you define the function outside of the scope of A, the symbol Enum
doesn't mean anything anymore by itself. You have to write

A::Enum A::foo()
{
return B;

}

regards,

Zeppe
hello

Apr 19 '07 #3
Gaijinco wrote:
How come that this is legal:

class A
{
enum Enum{B,C};
Enum foo()
{
return B;
}
};

But this isn't:

class A
{
enum Enum{B,C};
Enum foo();
};

Enum A::foo()
Enum is not in scope.

A::Enum A::foo()
{
return B;
}
Apr 19 '07 #4
On Apr 19, 5:38 pm, zeppe <z...@nospam.remove.all.this.email.it>
wrote:
Gaijinco wrote:
How come that this is legal:
class A
{
enum Enum{B,C};
Enum foo()
{
return B;
}
};
But this isn't:
class A
{
enum Enum{B,C};
Enum foo();
};
Enum A::foo()
{
return B;
}

If you define the function outside of the scope of A, the symbol Enum
doesn't mean anything anymore by itself. You have to write

A::Enum A::foo()
{
return B;

}

regards,

Zeppe
hello

Apr 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: BillyO | last post by:
I need a general mechanism for passing parameters to an API function I am designing, call it foo. Foo processes data, the operation used to process the data and the parameters for that operation...
3
by: Kenneth | last post by:
I want to define an enum for possible languages in my application. My enum look like this: Public Enum Languages English = 0 Portuguese = 1 End Enum How can i reuse this enum in the rest of...
5
by: Kaila | last post by:
I'm using metroworks codewarrior and can't solve a redeclariotin of type problem I have several classes and each of them need to have a custom type called enum X now what I was thinking is to...
4
by: Pierre Couderc | last post by:
I want to share enum between 2 classes C1 and C2: class C1 { public: enum shut {AAA,BBB, CCC}; shut m_C1; void set(shut &s) { m_C1=s;} };
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
8
by: Joe | last post by:
I have a .cs file which is linked to several other projects. All my classes in this file are defined as internal. I would like to have an enum defined as well in the namespace but I get an error...
13
by: toton | last post by:
Hi, I have some enum (enumeration ) defined in some namespace, not inside class. How to use the enum constant's in some other namespace without using the whole namespace. To say in little...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
12
by: Cmtk Software | last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI managed c++ and from C#. I defined the following enum in a VS dll project set to be compiled with the /clr switch: ...
3
by: Dean Mitchell | last post by:
Hi everyone, We have a c++ server application that we are writing a GUI client application for. To save our time and to avoid duplicating all the code and functionality that already exists in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.