Python to C++ translation?

szymon.rozga at gmail.com szymon.rozga at gmail.com
Mon Jul 18 19:43:01 EDT 2005


Ok so here's what you have:
A a(42);
B b(23.0);

a is now of type A, and b is now of type B. Right?

The constructor for class C takes in two arguments. The first one _has_
to be of type A and the second one _has_ to be of type B. This is how
you defined it.
This is why C(a,b) works fine. But C(b,a) shouldn't work because of how
you defined the constructor for C. You could add a second constructor
to C as follows:

C(B &_propB, A &_propA) {
    propA = &_propA;
    propB = &_propB;
}

which would let you call C(b,a).




More information about the Python-list mailing list