CS210 Lab: Introduction to Visual C++
The following are some questions that you can answer prior to the lab. These questions are specific to C++.
- What is a pointer?
- How would you declare a pointer called pOpponent to a class called AI_Opponent?
- How would you construct a new instance of AI_Opponent and assign it to pOpponent?
- Assuming the two previous steps worked, and that AI_Opponent has public member function draw, how would you call that function on pOpponent?
- How do you indicate that a pointer is pointing to nothing? What is such a pointer called?
- What happens if you try to access the data of a pointer to nothing?
- Suppose AI_Opponent's draw function draws a representation of the opponent based on a color that is unique to each instance. What would happen if you called that function on an invalid pointer?
- How could you prevent this from happening?
- What should you do when a pointer is done pointing at something?
- How do you clean up memory that was allocated specifically for a pointer?
For Answers, click
Back to the Introduction to Visual C++ Lab click
© 2015 Department of Computer Science, University of Regina.