hi all,

I have a class A that has a char* var, operator and methods.
In addition I have a global func(char*s). I would like to run this code from the main function by adding operators to my class, I need help writing them.

A* pA; 
... 
A** ppA = pA; 
func(*ppA);

thanks...

Hi BanKuZ, welcome to DaniWeb!

Which operator would you like to use? Maybe you can also post your class structure, I'm not sure I followed what is going on from what you posted.

David

Thank you for the fast replay,
I already have a MYclass* to char* conversion operator on the code and it work fine.
I having problems to convert from MYclass* to MYclass** and from MYclass* to char*.
I need them all to work simultaneously.

My class is very simular to this one:

class Mystring {
        public:
	char *s;
	Mystring(const char *);
	Mystring();
       ~Mystring(){}
    
        Mystring operator=(const char* str)
        {

           strcpy (s, str);
           return *this;
        }
            operator char *()//Conversion operator
	{
                return this->name; 
        }
	//...
};

Thank you for your help.

A dataType** is a pointer to a pointer to an instance of dataType (2-levels of indirection instead of 1).

int myInt = 150;
int *pMyInt = &myInt;
int **ppMyInt = &pMyInt;

You'll have to write your converter to return a pointer to the pointer you are trying to convert.

I know, tried these two:

Mystring** operator=( Mystring* A) 
          {
		Mystring** ppTemp= &A;
		return ppTemp;
           }
	
	operator Mystring **()//Conversion operator
	{
        return *this; 
        }

It didn't work. Am I doing something wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.