473,698 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

enum operator overloading in namespaces

Hey all. I posted this originally:

http://groups.google.com/group/comp....e4b76201ce17f1
I got the enums to work how I like but I am having a problem with the
overloading of the assignment operator:

namespace UserAffilliatio nType
{
enum UserAffilliatio nType //
user.getInfo.af filiations.affi liations_elt.ty pe
{
collegeNetwork = 1,
highSchoolNetwo rk = 2,
workNetwork = 3,
geographyNetwor k = 4
};
UserAffilliatio nType&
UserAffilliatio nType::operator =(UserAffilliat ionType& lhs, const
QString &rhs);
}

When mingw32 trys to compile the overloading statment I get

In file included from kernel/FBNKernel_inclu des.h:22,
from fbNotify.h:27,
from fbNotify.cpp:18 :
kernel/FBNKernelEnums. h:35: error:
`facebook::User AffilliationTyp e::UserAffillia tionType&
facebook::UserA ffilliationType
::operator=(fac ebook::UserAffi lliationType::U serAffilliation Type&,
const QString&)' must be a nonstatic member function
mingw32-make[1]: *** [release\fbNotif y.o] Error 1

Any ideas on how I can get something like this to work?

MyUserAffilliat ionType = MyQString;

Oct 10 '06 #1
1 4241
I'm trying
class UserAffilliatio nType
{
enum { vals };
};

It works for the operator, but how do i refrence to the enum?
th**********@gm ail.com wrote:
Hey all. I posted this originally:

http://groups.google.com/group/comp....e4b76201ce17f1
I got the enums to work how I like but I am having a problem with the
overloading of the assignment operator:

namespace UserAffilliatio nType
{
enum UserAffilliatio nType //
user.getInfo.af filiations.affi liations_elt.ty pe
{
collegeNetwork = 1,
highSchoolNetwo rk = 2,
workNetwork = 3,
geographyNetwor k = 4
};
UserAffilliatio nType&
UserAffilliatio nType::operator =(UserAffilliat ionType& lhs, const
QString &rhs);
}

When mingw32 trys to compile the overloading statment I get

In file included from kernel/FBNKernel_inclu des.h:22,
from fbNotify.h:27,
from fbNotify.cpp:18 :
kernel/FBNKernelEnums. h:35: error:
`facebook::User AffilliationTyp e::UserAffillia tionType&
facebook::UserA ffilliationType
::operator=(fac ebook::UserAffi lliationType::U serAffilliation Type&,
const QString&)' must be a nonstatic member function
mingw32-make[1]: *** [release\fbNotif y.o] Error 1

Any ideas on how I can get something like this to work?

MyUserAffilliat ionType = MyQString;
Oct 10 '06 #2

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

Similar topics

5
22388
by: Nils Petter Vaskinn | last post by:
I'm using an enum that's declared within a function (since I only need it within that function.) I can't find anything about this in "The C++ Programming Language" by Stroustroup and I don't have the standard. Is this legal? // test.cpp #include <iostream>
0
1316
by: Jonathan Mcdougall | last post by:
For use in many of my projects, I implemented an enum with scope using a class containing an enum with operator overloading. Wrapped in a macro, it gives class A { public: scoped_enum(Test) one, two, three
6
4692
by: PengYu.UT | last post by:
Hi, I have some problem when I use enum with stream. The code segment is listed below. I know if I change the first line to "int op;", there will not be any error. However, what I really want is of enum type. Is there any other way to fix this problem? Best wishes, Peng
4
6072
by: John Salerno | last post by:
I created this enumeration: enum Status { Off = 0, Red = 1, Yellow = 2, Blue = 4, Overload = 8
6
5411
by: TuxC0d3 | last post by:
Hi! I'm diving into the some more ++ specific aspects of c++ (and finally accepting that c++ is more than "a plus added to c" :), so that means using namespaces, templates, std::strings, lists, vectors, operator overloading and what not.. And i was wondering if there is a way to override the global dereference operator, so to be able to check the address that one tries to dereference. This gives the ability to throw an exception when...
34
11186
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?
11
3810
by: jakester | last post by:
I am using Visual C++ 2007 to build the code below. I keep getting linkage error. Could someone please tell me what I am doing wrong? The code works until I start using namespace for my objects. Error 1 error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char & __cdecl graph::operator<<(class std::basic_ostream<char,struct std::char_traits<char &,class graph::Node &)" (??6graph@@YAAAV?...
10
3774
by: yu_kuo | last post by:
I got series warning when using write enum type to a ostream using operator<<, like in call to `std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) ' A.cpp:60: warning: passing `NAME_ENUM' chooses `int' over `long int' Compiler gcc 3.4.3 When deserialize from an istream, I have to first using an int, and
9
481
by: Roger | last post by:
enum status { CONTINUE, WON, LOST } What do we really need to use enum for? I'm not sure what the use of it is really for... Maybe I just don't quite understand. My textbook says that these enumeration constants are integers and start at 0 if you don't assign the first constant in the enum. So, in this case, CONTINUE is 0, WON is 1, and LOST is 2. Why cant we just use integers instead? Why enum???
0
8672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9155
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, 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...
0
9018
jinu1996
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...
1
8890
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,...
1
6517
isladogs
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...
0
5859
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();...
1
3038
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
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.