Hey.
I'm trying to make a couple of enums work, however mingW isn't
compiling it because it says the previous declaration of none
conflicts. is there a way to solve this?
namespace Namespace
{
enum Gender // m or f
{
none = 0,
male = 1 << 0,
female = 1 << 1
};
enum LookingFor
{
none = 0,
friendship = 1 << 0,
dating = 1 << 1,
relationship = 1 << 2,
randomPlay = 1 << 3,
whateverICanGet = 1 << 4
};
} 5 4308 th**********@gm ail.com writes:
I'm trying to make a couple of enums work, however mingW isn't
compiling it because it says the previous declaration of none
conflicts. is there a way to solve this?
There is a plethora of ways dealing with enums, and unfortunately no
standard way everyone agrees upon.
Two popular ways are wrapping each enum in a class or namespace of
it's own:
namespace Gender
{
enum enum_t { ... };
}
or
class Gender
{
enum enum_t { ... };
};
With both approaches, you can have functions like toString that are
found by ADL.
I'd suggest you do something based on one of these approaches.
Regards,
Jens
Would you be kind to show how the boolean operators work on these?
Would it be like Gender::male?
Jens Theisen wrote:
th**********@gm ail.com writes:
I'm trying to make a couple of enums work, however mingW isn't
compiling it because it says the previous declaration of none
conflicts. is there a way to solve this?
There is a plethora of ways dealing with enums, and unfortunately no
standard way everyone agrees upon.
Two popular ways are wrapping each enum in a class or namespace of
it's own:
namespace Gender
{
enum enum_t { ... };
}
or
class Gender
{
enum enum_t { ... };
};
With both approaches, you can have functions like toString that are
found by ADL.
I'd suggest you do something based on one of these approaches.
Regards,
Jens
"th**********@g mail.com" <th**********@g mail.comwrites:
Would you be kind to show how the boolean operators work on these?
Would it be like Gender::male?
I'm not sure what you mean by boolean operators.
Gender::male would be a way to refer to an enumerator, eg.
std::string toString(Gender ::enum_t e)
{
switch(e)
{
case Gender::male: return "male";
case Gender::female: return "male";
}
throw std::runtime_er ror("invalid enum");
}
Regards,
Jens
Jens Theisen wrote:
std::string toString(Gender ::enum_t e)
{
switch(e)
{
case Gender::male: return "male";
case Gender::female: return "male";
}
throw std::runtime_er ror("invalid enum");
}
Bisexuality error.
--
Salu2
Thanks guys. I put each of them into a namespace. So when I delcare
one I do
facebook::Gende r::Gender name;
name = facebook::Gende r::male;
Julián Albo wrote:
Jens Theisen wrote:
std::string toString(Gender ::enum_t e)
{
switch(e)
{
case Gender::male: return "male";
case Gender::female: return "male";
}
throw std::runtime_er ror("invalid enum");
}
Bisexuality error.
--
Salu2
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Glenn Venzke |
last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an
enum. Is it possible to pass the item name without the enum name in your
calling statement?
EXAMPLE:
public enum EnumName
FirstValue = 1
SecondValue = 2
ThirdValue = 3
|
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;}
};
|
by: christopherlmarshall |
last post by:
Suppose you want to write a subclass of some existing class you are
importing from a module you didn't write and that you don't want to
study the internals of, and you want to define a data member i in your
constructor.
As in the following:
from module1 import A
class B(A):
|
by: John |
last post by:
Hi
Access 200. I have a replica and its associated master. When I try to open
any of these dbs, I get the message "This member of the replica set has
conflicts from synchronizing changes with other members. Do you want to
resolve these conflicts now?". When I select 'Yes', I get the below message.
Basically the conflict revolver is not coming up so I can't view and resolve
the conflicts. What is the problem and how can I fix it?
This...
|
by: Eric |
last post by:
After attempting to build a solution, I receive the error message; "One or
more dependent assemblies have version conflicts" "Do you want to fix these
conflicts by adding binding redirect records in the app.config file?"
I received this after changing the assembly version in two of the solution's
projects to
What does this error mean?
| |
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 snippet that I wrote today that gives me
an instant implementation of the pattern. I could easily just always
use such an implementation instead of a standard enum, so I wanted to
know what you experts all thought.
Is there a case for standard enums?
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello everyone,
Suppose I have two enums which has an item with the same names -- but
different values,
enum foo {
NAME = 100;
|
by: psychopif |
last post by:
I have a list of strings each represented by a number. I want those
string to be constant and put as litle hit as I can on the performance
of my application. The strings are mutualy exclusive, juste like an
Enum. I would use the Enum, but my string contains special caracter
and spaces. I would use a dictionary, but then the string could be
changed at runtime and it would add unnecesary overhead to my
application.
What would be the best...
|
by: puzzlecracker |
last post by:
What's the fastests way to find a number of values in enum.
I came up with this. but I think it's over kill.
enum Type
{
VAL1,
VAL2,
VAL3
}
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |