Can anyone help me with a computer science C++ assignment that i am struggling with?
The task is to design and implement a generic reference counted smart pointer class library, and
use the smart pointers to create a smart generic linked list class...
any help would be greatly appreciated...

8 Years
Discussion Span
Last Post by Alex Edwards

Have you even started?

A few ideas for your class that may help you get started--

*Implement a class that contains a pointer to the template-argument type
*Overload the ->, *, =, and [] operators
*The constructor should take a pointer to the template argument
*overload the << operator for the standard outputstream and your class to return the address of the encapsulated pointer
*Enable const version methods/operations such that the smart pointer is treated like a const smart pointer (and obviously a smart pointer to a const would have the const implemented in the template parameter).
*Make the destructor of the smart pointer properly deallocate memory for the pointer assigned to it (for simplicity assume all pointers are created via new, but if needed you can force your smart pointer to accept types that implement a common class with expected methods to determine if an object is created via new or not - this would take more knowledge of object creation though, via new). I'm sure a proficient C++ programmer knows of a better way around this #_#

For convenience, it may be helpful to have a string name() method and a std::size_t size() method for your smart pointer class.

I'm sure there are plenty of other ways to spiff up the class for convenience, but really all you need to do is think about the functionality of a pointer and how your class can emulate a smart pointer.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.