Interactive execution engineDeitel ch. 08
Pointer arithmetic and dereferencing
What just happened
arr is allocated on the stack as four contiguous ints. No heap involved yet — the size is known at compile time.
Variables
Live
- arr[0]
- 10
- arr[1]
- 20
- arr[2]
- 30
- arr[3]
- 40
nothing printed yetRubric Grading
An essay is marked, not scored
The rubric your instructor wrote is applied one criterion at a time, and you get each criterion's reasoning back with it. Not a number out of ten with nothing attached.
Where the marker is not confident, your instructor reviews that criterion before the grade is released.
This program is correct as written, but it stops being correct the moment the pointed-to object is a derived type. Explain what the delete does here, and what changes if Shape's destructor is not virtual.
class Shape {
public:
virtual ~Shape() = default;
};
class Circle : public Shape {
public:
~Circle() override { radius_ = 0; }
};
Shape* make() { return new Circle; }
int main() {
Shape* s = make();
delete s;
}Correct: delete s calls through the pointer's static type, which is Shape.
Names dynamic dispatch and ties it to the virtual keyword on ~Shape.
Right mechanism, but stops at “only ~Shape runs”. Does not name the resource Circle held that then leaks.
A graded answer, shown the way the rubric scores it.
Memory model
Where the variables actually live
int* ptr = nullptr; int count = 42;01/04Declaration
Nothing allocated yet. The stack alone is enough for anything whose size the compiler can work out.
Two locals are created in the current stack frame. ptr is a pointer initialised to null, so it points at nothing and any dereference would be a fault.
Try oneDeitel ch. 08
Syllabus
Eight chapters, in the order you will meet them
Materials, practice sets, and exam questions are all tagged to the chapter they come from.
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
Platform Modules
Built Specifically for CS.102 Coursework
assess
Take the midterm
Every official exam is timed and individual. Questions and answer options are shuffled per student, and your answers save continuously as you go.
practise
Practise with AI Rubrics
Generate custom drills on any Deitel chapter at any difficulty. Get deep error breakdowns, ideal model solutions, and concept explanations.
ask
Ask when you are stuck
The AI tutor works through C++ concepts with you, line by line. It automatically locks during live exam sessions to uphold academic standards.
Before you start — you need an active @must.edu.eg address and a modern browser. Midterms run 60–75 minutes, timed from the moment you open the paper.
Register for CS.102
Use your university email address. You will land in the dashboard, where this term's exams and the current week's materials are waiting.