S
Suki
Hi all,
I'm facing a rather strange design problem. Let me explain it.
I'm writing an application, which deals with strings extensively. So
decided to write a new string class (CXString say) for my application.
But majority of its member functions are the same as the ones in
std::string class.
So I've decided to derive CXString from std::string class. No problem
till now. But now i'm facing with the problem of invoking CXString
class.
My class looks some thing like this.
class CXString : public std::string
{
public:
CXString() ; // No argument constructor ;
CXString (const std::string&) ; // One argument constructor
// Member functions goes here .
} ;
Now my question is, is it valid to invoke a derived class with a base
class object.??
I'd like to call my CXString object like this.
CXString my_str ;
my_str.find_first_of (...) // member function from std::string class
my_str.my_string_function (...) // Member function from CXString class.
What I'd like to know is whether there's any problem with my design. If
not suggest me a new design.
Thanks in advance,
Surya
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
I'm facing a rather strange design problem. Let me explain it.
I'm writing an application, which deals with strings extensively. So
decided to write a new string class (CXString say) for my application.
But majority of its member functions are the same as the ones in
std::string class.
So I've decided to derive CXString from std::string class. No problem
till now. But now i'm facing with the problem of invoking CXString
class.
My class looks some thing like this.
class CXString : public std::string
{
public:
CXString() ; // No argument constructor ;
CXString (const std::string&) ; // One argument constructor
// Member functions goes here .
} ;
Now my question is, is it valid to invoke a derived class with a base
class object.??
I'd like to call my CXString object like this.
CXString my_str ;
my_str.find_first_of (...) // member function from std::string class
my_str.my_string_function (...) // Member function from CXString class.
What I'd like to know is whether there's any problem with my design. If
not suggest me a new design.
Thanks in advance,
Surya
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]