473,396 Members | 1,940 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.

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.cpp(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.cpp(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 2916
"Angus" <an*********@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.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.cpp(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.cpp(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
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...
9
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...
5
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...
28
by: Act | last post by:
Why is it suggested to not define data members as "protected"? Thanks for help!
6
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
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...
5
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...
2
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...
3
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,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
0
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...

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.