468,734 Members | 2,218 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,734 developers. It's quick & easy.

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 2705
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Penn Markham | last post: by
28 posts views Thread by Act | last post: by
6 posts views Thread by marco_segurini | last post: by
5 posts views Thread by Matthew Hood | last post: by
2 posts views Thread by Adam Hartshorne | last post: by
3 posts views Thread by Jon Rea | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.