473,396 Members | 1,755 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,396 software developers and data experts.

enum visibility problem

I have an enum like this

file1.cpp
enum e {e1, e2};
extern void fun();
void main()
{
fun();
}
file2.cpp
extern enum e;
void fun()
{
enum e ee= e1; // Compilation error "error C2065: 'e1' : undeclared
identifier"
// How do i access the enum here, if i dont define it in a header file.
}
Oct 1 '05 #1
2 5472
Sandy wrote:
I have an enum like this

file1.cpp
enum e {e1, e2};
extern void fun();
void main()
main() must return int.
{
fun();
}
file2.cpp
extern enum e;
void fun()
{
enum e ee= e1; // Compilation error "error C2065: 'e1' : undeclared
identifier"
// How do i access the enum here, if i dont define it in a header
file.
You can copy the definition to file2.cpp, but honstely, I think it's better
to move the definition to the header. This is just the same as other user
defined types. If they are only forward declared, you cannot do much with
them.
}


Oct 1 '05 #2
Sandy wrote:
I have an enum like this

file1.cpp
enum e {e1, e2};
extern void fun();
void main()
{
fun();
}
file2.cpp
extern enum e;
void fun()
{
enum e ee= e1; // Compilation error "error C2065: 'e1' : undeclared
identifier"
// How do i access the enum here, if i dont define it in a header file.
}


Err, you define it in the header file. Put it in the header file so you
can share the definition between different source files. That's what
header files are for.

john
Oct 1 '05 #3

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

Similar topics

4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
1
by: Bill Cohagan | last post by:
I've got an abstract class (say foo) and I'd like to define an Enum (say bar) within that class so that I can then refer to foo.bar.<one of the enum labels> from within other parts of the program....
18
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I have created an enum list like this: enum myEnum : int { This = 2, That, NewVal = 10, LastItm
10
by: kar1107 | last post by:
Hi all, Can the compiler chose the type of an enum to be signed or unsigned int? I thought it must be int; looks like it changes based on the assigned values. Below if I don't initialize...
11
by: -D- | last post by:
How can I turn the visibility of the xml control on or off? <%@ Control Language="c#" AutoEventWireup="false" Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar"...
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...
3
by: dev_15 | last post by:
Hi, I have this problem that i want to use an enum as a return value of a private method in my class, but compiler won't let me use as such Code here: class CDisplayUtil { public: enum...
6
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;
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
tracyyun
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...

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.