tgckpg wrote: |
---|
I've learnt AS2/3, JS and PHP, and I figured out C++ is an entirely different language and it's conflicting with my pre-concept of programming language. |
Definitely, each language is totally different and requires a different way of thinking. It's hard to get used to a new language - programs I write in Python or Perl still look suspiciously like C programs with different syntax - but it's generally not a good idea to mix two languages into one. It makes a huge mess.
tgckpg wrote: |
---|
Anyway, could you please tell me which part is C and which is C++? |
It's hard because the parts where you've used C-style code are mixed into the C++ parts. You're using char* for strings, for example, or printf for output. It's ok to use C functions in C++ code, that's why the C standard library is provided, but mixing C input/output and C++ input/output is not a good idea, it would be like putting two kinds of fuel into a car and trying to drive.
Maybe you should read over the whole C++ tutorial here:
http://cplusplus.com/doc/tutorial/
Then you can go back to it or use this reference if you get stuck:
http://cplusplus.com/reference/
tgckpg wrote: |
---|
using $ as prefix is very convenient because when I type "$", the editor gives me the list of "$" prefixed variables and class.
If you say so, it's OK I won't use $ as you recommended. |
I take it you're using a PHP IDE then? Find a C++ IDE like Code::Blocks or NetBeans, those are quite popular and fully-featured IDEs which will also give you autocomplete options.
tgckpg wrote: |
---|
So the problem causes by the memory is being used.
Is that $a and $b sharing the same address or cin.getline uses? |
It looks like it. There could be other problems that I didn't see, though.
tgckpg wrote: |
---|
oh, and why it could run normally is debug mode? |
That's what that stuff about "Heisenbugs" and the Observer Effect is about. The debugger changes the internal state of your program in a way that, just by chance, makes it work.