name conflicts in enum

Hello everyone,

Suppose I have two enums which has an item with the same names -- but different values,

enum foo {

NAME = 100;
}

enum goo {

NAME = 200;
}

Are there any ways to specify whether I need to access NAME in foo or NAME in goo?

thanks in advance,
George
[377 byte] By [George2] at [2007-11-20 11:50:04]
# 1 Re: name conflicts in enum
You cannont distinguish between two enumeration values. Theres workaround that lets you isolate these enumerations from each other. Create two new namespaces in your header file and include the header files in each namespace separately:

// Header file
namespace foo
{
#include "foo.h" // contains enum foo { NAME = 100 };
}

namespace goo
{
#include "goo.h" // contains enum foo { NAME = 100 };
}

// .cpp file
// access foos NAME:
xyz = foo::NAME

// access goos NAME:
abc = goo::NAME
GNiewerth at 2007-11-9 1:26:17 >
# 2 Re: name conflicts in enum
Thanks GNiewerth,

Your method works!

You cannont distinguish between two enumeration values. Theres workaround that lets you isolate these enumerations from each other. Create two new namespaces in your header file and include the header files in each namespace separately:

// Header file
namespace foo
{
#include "foo.h" // contains enum foo { NAME = 100 };
}

namespace goo
{
#include "goo.h" // contains enum foo { NAME = 100 };
}

// .cpp file
// access foos NAME:
xyz = foo::NAME

// access goos NAME:
abc = goo::NAME

have a good weekend,
George
George2 at 2007-11-9 1:27:20 >