|
-
April 20th, 1999, 01:59 PM
#1
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.
-
April 21st, 1999, 10:13 PM
#2
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.
-
April 22nd, 1999, 02:15 AM
#3
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)
{
}
-
April 22nd, 1999, 08:29 AM
#4
Re: Deriving a class from CString
Thanks that seemed to work...... Thank you very much.... This is an excellent site.
-Larry
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|