Reputation:
I'm just being introduced to C++, and want to know a basic question.... What happens when using C++? Is there anywhere I can see a working example? Textbooks break it down, segment by segment. I would really like to SEE what happens. ANY suggestion would be appreciated. Hope MY question is not too vague. Thanks!
Upvotes: 2
Views: 398
Reputation: 13972
If you want to see it step by step:
Set a breakpoint at the first line and start in debug (F5 in Visual Studio). You can step through the program step-by-step and see what's going on with varying granularity (Step Over or Step Into - usually F10 and F11 in Visual Studio). Stepping into will follow a function call whereas F10 will call it, and step forward over it after it returns.
If you want to see what's going on at a lower level you can use disassemble on your code.
I've used Visual Studio/Windows stuff here b/c that's what I'm most used to but these things are in every major C++ IDE I've seen.
Upvotes: 0
Reputation: 10184
When I use C++, other programmers bow down to me because of my awesomeness. But that's just my experience.
Upvotes: 2
Reputation: 116674
You get into the office around 8:30am, get some tea, and you sit down and run a program called an IDE. It lets you type code with the keyboard, such as:
(*m_pHopeThisIsntNull)->doIt();
You can then hit F5 and the code runs and you find out it doesn't work the way you expected. Pretty soon it's 5:30pm.
Upvotes: 10
Reputation: 224069
You can use a debugger to execute your program step by step, looking at the variables. If that's not enough, debuggers can also show you the a disassembled version of the machine code along with the processor's registers.
Would that help?
Upvotes: 0
Reputation: 2567
Sounds like a short session with your TA (at an American university, this is the graduate student who helps with the hands-on stuff, does the grading, etc., as a help to the professor) is in order. Get him/her to show you how to use whatever IDE (integrated development environment) your class is requiring/suggesting. Or wait for your lab session, where you will learn this.
Upvotes: 0
Reputation: 91462
If you are trying to learn C++, you cannot just read from the textbook -- programming is learned best through hands-on practice. You should get a C++ compiler and run through the textbook examples yourself.
Upvotes: 3