我是 C++ 新手,所以我提前为我的问题的平凡性质道歉。
我被要求将以下内联函数从头文件移动到源文件。但是我正在努力在源文件中获得正确的语法。这是头文件中的内联函数:
class G1FRViewOption
{
public:
enum ViewType {partyView, contraView, unknown} ;
G1FRViewOption() : m_view (nullString )
, m_viewType (unknown )
, m_isValid (false ) {initialise();}
G1FRViewOption(const RWCString view) : m_view (view )
, m_viewType (unknown )
, m_isValid (false ) {initialise();}
void initialise()
{
static RWCString views[] = {"party","contra"} ;
for (int vt=counterpartyView; vt<unknown; vt++)
if (m_view.compareTo(views[vt], RWCString::ignoreCase)==0)
{
m_viewType = (ViewType) vt ;
m_isValid = true ;
break ;
}
}
RWCString getErrorMessage()
{
return "Invalid " + getFieldLabel() + " given. Valid values are party, contra.";
}
G1FRViewOption & operator = (const G1FRViewOption & other)
{
this->m_view = other.m_view ;
this->m_viewType = other.m_viewType ;
this->m_isValid = other.m_isValid ;
return *this ;
}
RWBoolean is (ViewType viewType) const {return viewType == m_viewType ;}
RWBoolean isValid () const {return m_isValid ;}
const RWCString & toString () {return m_view ;}
static const RWCString & getFieldLabel () { static RWCString value = "View" ; return value ; }
static const FieldDefinition & getFieldDefinition () { static const FieldDefinition fd (getFieldLabel(), 13) ; return fd ; }
private:
RWCString m_view ;
ViewType m_viewType ;
RWBoolean m_isValid ;} ;
任何帮助将不胜感激。
提前谢谢了。
C++新手!