Hello.
I have a situation where i have two classes represented as "A" and "B", class A can be converted to class B, but not other way around.
pseudo code:
class A
{
public:
A(int One) : one(One);
int one;
};
class B
{
public:
B(int One, int Two) : one(One), two(Two);
int one, two;
};
void func(A & objA);...
//.cpp
A a(1);
B b(2,3);
func(b);
I require the conversion of the classes and unsure what operator to overload.
In current example the func would have a object "A" with int "one" being value 2.
I tried
class A
{
public:
A operator=(B b);
int one;
};
A A::operator=(B b)
{
return A(b.one);
}
and my compiler still complains that it cannot take it.
EDIT::
It seams i overlooked a simple solution it was...
class A
{
A(B b);
};
My feelings
http://www.the-mainboard.com/styles/default/xenforo/eastereggs/devine.gif