PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Aurora

Implement a reference-counted smart pointer

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of C++ resource management, ownership semantics, RAII, and reference counting implementation within the coding and algorithms domain, emphasizing pointer semantics and object lifetime.

  • hard
  • Aurora
  • Coding & Algorithms
  • Software Engineer

Implement a reference-counted smart pointer

Company: Aurora

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Implement a minimal C++ reference-counted smart pointer similar to `std::shared_ptr`. Requirements: - Create a class template `SharedPtr<T>` that manages a heap-allocated `T*`. - Use RAII: the managed object must be deleted exactly once when the last `SharedPtr` owning it is destroyed. - Support: - Default constructor (null pointer) - Constructor from raw pointer `T*` - Destructor - Copy constructor / copy assignment (increase reference count) - Move constructor / move assignment (transfer ownership, leaving the source null) - `T& operator*()`, `T* operator->()`, `T* get() const` - `size_t use_count() const` - `void reset(T* p = nullptr)` - Handle self-assignment correctly and avoid memory leaks/double-free. You may ignore thread-safety unless you explicitly choose to support it.

Quick Answer: This question evaluates understanding of C++ resource management, ownership semantics, RAII, and reference counting implementation within the coding and algorithms domain, emphasizing pointer semantics and object lifetime.

Related Interview Questions

  • Compute streaming sliding-window minimums - Aurora (medium)
  • Find viewing direction that sees most points - Aurora (medium)
Aurora logo
Aurora
Jan 28, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

Implement a minimal C++ reference-counted smart pointer similar to std::shared_ptr.

Requirements:

  • Create a class template SharedPtr<T> that manages a heap-allocated T* .
  • Use RAII: the managed object must be deleted exactly once when the last SharedPtr owning it is destroyed.
  • Support:
    • Default constructor (null pointer)
    • Constructor from raw pointer T*
    • Destructor
    • Copy constructor / copy assignment (increase reference count)
    • Move constructor / move assignment (transfer ownership, leaving the source null)
    • T& operator*() , T* operator->() , T* get() const
    • size_t use_count() const
    • void reset(T* p = nullptr)
  • Handle self-assignment correctly and avoid memory leaks/double-free.

You may ignore thread-safety unless you explicitly choose to support it.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Aurora•More Software Engineer•Aurora Software Engineer•Aurora Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.