Deriving a class from CString
I derived a new class from CString. Here is my code:
//ScriptXSourceString ~ SXSrcS
class SXSrcS : public CString
{
public:
// SXSrcS();
// ~SXSrcS();
getRVal(CString &, CString);
};
#endif
I then creat an object:
SXSrcS temp = "this is a test";
I get the following error:
OP1QuestionList.cpp(441) : error C2440: 'initializing' : cannot convert from 'char [15]' to 'class SXSrcS *'
My question is what is the deal..How come I am getting this error.
Re: Deriving a class from CString
You need to create some suitable constructors. You have none. see CString for the ones you will want to have.
Re: Deriving a class from CString
When you derive a class from another class, you can use the members and methodes from that class. The constructors are the exception. You have to specify your own constructors(which can make use of the constructors of the base class)
Example:
SXSrcS::SXSrcS(const char *pszChar) : CString(pszChar)
{
}
Re: Deriving a class from CString
Thanks that seemed to work...... Thank you very much.... This is an excellent site.
-Larry