We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
References, Pointers, Ownership
C++Distinguish owning objects from borrowed references and pointers. Choose interfaces that communicate access and keep borrowed data valid.
This track uses C++. You can make it your practice mode to browse related content across the site.
4 exercises
Explore freely. Sign in to keep your progress.
Your learning sequence
- 1 Not solved yet. Say it in the signature Practice · Easy
- 2 Not solved yet. A raw pointer owns nothing Practice · Medium
- 3 Not solved yet. Give an allocated object an owner Practice · Medium
- 4 Not solved yet. Break an ownership cycle with weak_ptr Practice · Hard
Check yourself
4 questions · not saved while you're signed outUse these questions to check your understanding and compare explanations. Your score does not affect track completion.
In C++20, is deleting this Derived through Base* well-defined?
Choose one answer to reveal the explanations. Answers are kept only while this page is open.
struct Base {
virtual void f() {}
~Base() = default;
};
struct Derived : Base {
~Derived() = default;
};
int main() {
Base* b = new Derived;
delete b;
}