Hi guys, I have recently been given a python code and have been tasked to translate it to C++ programming language under Eclipse IDE. However, I am new to C++ and the eclipse IDE so I am unsure of what to translate and what to keep. Is it possible if anyone could tell me some basics to note ( e.g. what to translate, what to keep etc) . Thanks. I can present the code here if anyone needs it.
Python code is generally pretty straightforward, you'll likely need to copy all of the core ideas of the code and add some additional functions to get things working the way you need.
I work for a company that has a large code base in good old vb6, which is the equivalent of latin in spoken language (dead, eh?)
Normally the process I take is this:
1. Analyze the existing code, explore the foundation, and run through a couple tests (either using a debugger or pen and paper if debugging isn't available (vb6 doesn't like my computer, sometimes pen and paper are the only option))
2. Define the purpose of the code
3. Convert the code into pseudocode, using the purpose as the guideline for any grey areas
4. Step through the pseudocode and implement the code in the target language.
Sometimes you can skip a most of this process, but if you encounter any type of complexity having a gameplan is super handy.
Thanks for your suggestion but do you or anyone reading this happen to know the notable differences between both programming languages, for example you have to declare your variables in c++ but not in python. Appreciate it if anyone could help list the other differences out, thanks!
So many, that it would be impractical to list in a forum post. Python uses all sorts of concepts and constructs that aren't in C++, and vice versa. Presumably you're experienced in Python? I think you're just going to have to follow wizebin's general approach, and just learn the C++ you need to know to re-implement what the Python code does.
That's kind of a tall order, but presumably whoever assigned you this task is aware that you're inexperienced in C++, and so understands that it's going to take time for you to learn what you need to know to do it.