Python to C++ conversion substituting vectors for lists in a recursive function

Peter Otten __peter__ at web.de
Wed Mar 23 09:51:34 EST 2005


lugal wrote:

Your code has an undeclared int i in main().

> gseq.erase(0);

I think erase() takes a pointer, not the element index:

gseq.erase(qseq.begin());

> in the recursive function. Is my C++ translation accurate from the
> original Python?

Coming from a Python background, you should have learned that the proper way
to answer that question is to write a test suite.

Generally speaking, if you want to learn a new language it is probably
better to extend examples written in that language than to translate code
written in another language you are already familiar with. What is
idiomatic in one language may be clumsy and inefficient in another.

Peter

PS: Your post is off-topic in c.l.py, consider asking for further/better
advice in a C++ newsgroup.







More information about the Python-list mailing list