By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,864 Members | 1,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,864 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
"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.