473,756 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why moving a function from protected to public area in class causes error C2556

Why moving a function from protected to public area in class causes
error C2556 - overloaded function differs only by return type

I have a protected function called GetState like this:

enum EState GetState(void) const throw();

If I move this function from protected: to public: I get this compile
error:

xbasicsocket.cp p(247) : error C2556: 'enum CXBasicSocket:: EState
__thiscall CXBasicSocket:: GetState(void) const' : overloaded function
differs only by return type from 'enum EState __thiscall
CXBasicSocket:: GetState(void) const'
\xbasicsocket.h (154) : see declaration of 'GetState'
\xbasicsocket.c pp(247) : error C2371: 'GetState' : redefinition;
different basic types
\xbasicsocket.h (154) : see declaration of 'GetState'
In the cpp file it is declared like this:

enum CXBasicSocket:: EState CXBasicSocket:: GetState(
) const throw()
{
return m_eState;
}

Why am I geting this problem? How do I resolved?

Jul 19 '07 #1
1 2947
"Angus" <an*********@gm ail.comwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
Why moving a function from protected to public area in class causes
error C2556 - overloaded function differs only by return type

I have a protected function called GetState like this:

enum EState GetState(void) const throw();

If I move this function from protected: to public: I get this compile
error:

xbasicsocket.cp p(247) : error C2556: 'enum CXBasicSocket:: EState
__thiscall CXBasicSocket:: GetState(void) const' : overloaded function
differs only by return type from 'enum EState __thiscall
CXBasicSocket:: GetState(void) const'
\xbasicsocket.h (154) : see declaration of 'GetState'
\xbasicsocket.c pp(247) : error C2371: 'GetState' : redefinition;
different basic types
\xbasicsocket.h (154) : see declaration of 'GetState'
In the cpp file it is declared like this:

enum CXBasicSocket:: EState CXBasicSocket:: GetState(
) const throw()
{
return m_eState;
}

Why am I geting this problem? How do I resolved?
Most likely, it isn't recognizing EState and CXBasicSocket:: EState as being
the same. In the prototype change it to CXBasicSocket:: EState as the return
value and see if the error goesa away.
Jul 19 '07 #2

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

Similar topics

9
4964
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
9
4996
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class pointer which points to an instance of a derived class, but when I pass that base class pointer into a function, it can't access the derived object's public functions. Although, the base class pointer does call the appropriate virtual function...
5
2153
by: amit kumar | last post by:
I am calling a function which returns pointer to a map. The declaration of the map is map<int,vectxyz*>. vectxyz is a vector containing pointer to a class xyz. For map<int,vectxyz*>* p1 In the called function, I am using p1->find(1) which is returning a valid iterator and not going to the end. I am returning p1 from the called function. But in the calling function, find(1) is going to the end, i.e unable to find the key 1, which was...
28
3426
by: Act | last post by:
Why is it suggested to not define data members as "protected"? Thanks for help!
6
2626
by: marco_segurini | last post by:
Hi, the following sample code shows a compiler error I get trying to build some old code with the last CL compiler (vers 13.10.3077): //----- begin #include <iostream> namespace ns {
6
4410
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the same invocation from a DistantlyRelated class. What actually happened was that the compiler produced: error C2247: 'A::function' not accessible because 'CloselyRelated' uses 'private' to inherit from 'A' I'm guessing that the above compiler...
5
4332
by: Matthew Hood | last post by:
Here's a interesting question for the guru's out there. I've created a VB.NET class library with a couple of forms that I have successfully got to work from within MS Access using COM interop and VBA. (Working, meaning it hasn't crashed on me yet... ;-). I Would anybody know how to take this VB.NET Winform (using it's handle, subclassing, or other means) and set it's parent to be the Access MDI client area so that it will behave as if...
2
3595
by: Adam Hartshorne | last post by:
I have just upgraded to Visual Studio 2005 and have loaded in a project i have been working on, and the code compiles ok but fails to link correctly, as shown below. Any suggestions about what is wrong would be much appreciated, 1>msvcprt.lib(MSVCP80.dll) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class...
3
4154
by: Jon Rea | last post by:
Hello all, Sorry if this is long, but I wanted to be specific... Can anyone shed any light on the following errors in the context of the following example code: cullMethod1(); // compiles, but not what we want - we cant access m_Exclustions
0
9456
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
9275
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
9872
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
7248
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
6534
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();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.