How IDE “learns” my code with logic and structure?
Once I use an IDE to compile my C++ code, this IDE seems know everything of my code: I could find the most original definition of any element in my code, no matter how deep it is from usage to definition.
the IDE seems know: 1.my code logic 2.my code structure
How IDE could do this?
For example, it scans files to find all symbols declarations, their membership in scopes, other symbols (classes, structs and so on). Then if it find a reference to the symbol, it already knows, where it is declared. Internally, IDE uses graph models to represent the tree of dependencies and calls. If you're interested in this topic, I recommend you to read this book: http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools