Abstract class,interface

Hello. I have some problem.
I have interface with 2 function


class Convert{
virtual string ob_to_str(Convert *)=0;
virtual Convert* str_to_ob(string s)=0;
};

then i have next class

class A:public Convert{

How to convert String to Object??
How to convert object to String???


}
I would declare function ob_to_str the following way

virtual string ob_to_str() const = 0;

and define it in the derived class as

1
2
3
4
string A::ob_to_str() const
{
   return ( "A" );
}
1
2
3
4
5
6
7
8
9
10
11
12
struct Object
{
    Object(std::string s)
    {
        //instantiate from string
    }

    operator std::string()
    {
        return ""; //convert to string
    }
};
Unfortunately an interface cannot easily require sub-classes to expose a public constructor with a specific signature.
Topic archived. No new replies allowed.