-2

Possible Duplicate:
Convert Python program to C/C++ code?

I can code in python but have difficulty in writing c++ code, but I have to submit the c++ code, one of my senior suggested me to write the code in python and then write the python code to convert it into c++, I Google it out but cannot find a good guide, Can anybody help me? Your help will be appreciated. Thank you.

Community
  • 1
  • 1
shreya
  • 297
  • 3
  • 7
  • 15
  • 1
    Did you mean - writing a converter? Learning C++ will take less time I suppose. – Swapnil Jan 10 '13 at 06:13
  • @ Karthik - Thankyou for immidiate reply, I am not switching to c++ because of the speed, so I am least bother about speed, I just want the code in c++. And looked foe cython but my system is not supporting cython. – shreya Jan 10 '13 at 06:19
  • @Swapnil - I want to know if any online source is available to convert python to c++. – shreya Jan 10 '13 at 06:21
  • Possible duplicate of [Convert Python program to C/C++ code?](https://stackoverflow.com/q/4650243/608639) – jww Nov 21 '19 at 13:31

2 Answers2

3

I wouldn't recommend writing it in Python and then converting to C++. Not only is it double the effort, but the style of Python code is different from C++ code, mainly because Python is dynamically typed and C++ is statically typed.

user1610015
  • 6,561
  • 2
  • 15
  • 18
1

I don't have a solution for you but I can only reinforce what others have posted: don't! Even if such a solution exists, the code would very likely be quite bad and inefficient (i.e. because the c++ would have to emulate the dynamic nature of python). Whoever required you to submit c++ code probably had a reason and he will either realize you "cheated" or think you're a very bad programmer. Is this acceptable?

Tannin
  • 488
  • 5
  • 11
  • I agree with you, I am working in a project, my partners in project are good at C/C++, but I am not, I told them,And they have never used python, so the final output of the project should be in C++, we all have agreed to this, I discussed this with my project head and he suggested me to try getting python to C convector. So everybody in my project have an idea what I am planning to do. – shreya Jan 10 '13 at 06:54