English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

it is a c++ interview question

2007-03-23 22:17:51 · 3 answers · asked by engg 1 in Computers & Internet Programming & Design

3 answers

plz try

www.in.programming.com

2007-03-23 22:24:41 · answer #1 · answered by ashish_jain_ajmer 2 · 0 1

As far as large programs are concerned (such as a 3D racing game), there's no way you can reproduce the C++ source code from their binary files. For simple programs, however, you should be able to do that.

Here's how & why:

A binary file is a file that results when you build a C++ program using your compiler and linker. In order to create a binary, the compiler and the linker go through certain specific steps.

If you know these steps, then, logically, in order to convert the binary back to the C++ code you simply have to trace these steps backwards.

In the case of large programs, however, that's easier said than done. For complex applications, these steps of conversion are very very complicated. They are, therefore, almost impossible to understand and trace backwards.

In the case of a simple program, on the other hand, the path from C++ code to the binary is pretty straightforward. Consequently, it is relatively far easier to go back from a binary file and arrive at C++ code.

Sure enough, software applications are available that can do the above for you. They are called disassemblers and decompilers. A disassembler converts a binary to a assembly language code and a decomplier, as the name suggest, does the opposite of what a compiler does and converts assembly code into a C++ (or any other high level language) code.

2007-03-24 06:27:57 · answer #2 · answered by Gurinder 1 · 0 0

no you cant. the reason is when you compile, the compiler optimise's the code so it will run faster and/or with the least amount of lines of code as possible.

now, there may be some software that attempts to generate c++ source code from the binary file, BUT it will not (and can not) reproduce the original source code. first, it doesn't know the names of the variables, it doesn't know how everything was structured, or the names of the functions used. all of these are lost when the code is compiled. it also can not know what code was optimized.

2007-03-24 09:04:25 · answer #3 · answered by justme 7 · 0 0

fedest.com, questions and answers