You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First problem.
I have two classes A and B.
I would like to have class B to be implicit convertible to A, but I would like not to expose the A(B) constructor in python, because I want to construct my object with factory methods only.
Can I achieve that in some ways?
Second problem.
I have a hierarchy.
A is the base class, B and C derives from A.
B and C are impl convertible from a string.
I have a container class with a method to add a vector of A.
I would like to make use of the implicit conversions of the subclasses of A:
I mean I would like to call the add with a vector which can contain not only instances of A, but also strings.
Can I do that?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi.
First problem.
I have two classes A and B.
I would like to have class B to be implicit convertible to A, but I would like not to expose the A(B) constructor in python, because I want to construct my object with factory methods only.
Can I achieve that in some ways?
Second problem.
I have a hierarchy.
A is the base class, B and C derives from A.
B and C are impl convertible from a string.
I have a container class with a method to add a vector of A.
I would like to make use of the implicit conversions of the subclasses of A:
I mean I would like to call the add with a vector which can contain not only instances of A, but also strings.
Can I do that?
Thanks for the help
Beta Was this translation helpful? Give feedback.
All reactions