So I can just edit out the other file codes? do you mean I only need to look at main.cpp and go step by step through each line or just main()?
|
there are different ways to approach it.
1) you could understand the code, and just write some simple pcode to represent what it does.
2) you could search and replace and clean, eg change cout to print, >> just remove them, cut all the ; end of lines, remove all the #define lines, cut all the voids, etc. Basically replace or cut all the c++ specific jargon/gibberish stuff.
3) you can line by line it, but that is likely to give bloated pcode. Pcode usually just wants enough info to rebuild it in any language, so the goal is to get rid of language specific house keeping nonsense that is only there to enable the language to work and leave the things that define what it DOES and HOW it does it. {} in pcode for blocks of code may be swapped for begin/end words, or left in, depending on how the people wanting the pcode or its author feels about it.
4) you could convert it to pascal, which is darn near compiled pcode.
I get that this could be your homework, but in the field, it is rare to see more than a pageish of pcode. Its usually used to describe ONE function or ONE algorithm, not a giant OOP program with a dozen files etc. There isnt a lot of point in writing that much of it as it is a large time investment in writing something that has to be rewritten again 'for real' soon afterwards. And it is doubly nuts to write pcode from existing code at the full program level; you already have the code so its not going to be used to write it, so what is the purpose?! Again, the usual use is like if you google shellsort on the wiki, its expressed in pcode rather than c++ so anyone can write it in basic or C or java or python or whatever else. But you won't see "a ms-paint like example program" in p-code.