Register on the forum now to remove ALL ads + popups + get access to tons of hidden content for members only!

Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General


Thread Tools Rate Thread Display Modes
Old 02-15-2016, 01:45 AM   #1
Registered User
Join Date: Dec 2013
Location: Banglore
Posts: 336
Send a message via AIM to chinmay.sahoo Send a message via MSN to chinmay.sahoo
Arrow What is a smart pointer?

A smart pointer is a C++ class that mimics a regular pointer in syntax and some semantics,but it does more. Because smart pointers to different types of objects tend to have a lot of code in common, almost all good-quality smart pointers in existence are templated by the pointee type, as you can see in the following code

class SmartPtr
explicit SmartPtr(T* pointee) : pointee_(pointee);
SmartPtr& operator=(const SmartPtr& other);
T& operator*() const
return *pointee_;
T* operator->() const
return pointee_;
T* pointee_;
SmartPtr aggregates a pointer to T in its member variable pointee_. That's what most smart pointers do. In some cases, a smart pointer might aggregate some handles to data and compute the pointer on the fly.

The two operators give SmartPtr pointer-like syntax and semantics. That is, you can write

class Widget
void Fun();
SmartPtr sp(new Widget);
Aside from the definition of sp, nothing reveals it as not being a pointer. This is the mantra of smart pointers: You can replace pointer definitions with smart pointer definitions without incurring major changes to your application's code. You thus get extra goodies with ease. Minimizing code changes is very appealing and vital for getting large applications to use smart pointers. As you will soon see, however, smart pointers are not a free lunch.

Hair Building Fiber
Step Up Height Increaser
Sandhi Sudha
chinmay.sahoo is offline   Reply With Quote


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the Google Smart SEO ? sonamsharma Search Engine Optimization 4 03-14-2016 02:31 AM
Which smart phone do you like ? sana8745 General Discussion 22 03-13-2015 08:51 AM
What is the smart SEO ? Ruby707 Search Engine Optimization 0 01-17-2015 08:38 AM
How to increase performance of a Android smart phone and Tab sbz14 Post your ad here 0 11-11-2014 09:29 PM
Smart Phone Compliance Complete Web Promotion 1 01-20-2014 12:52 AM

All times are GMT -7. The time now is 04:45 PM.

Powered by vBulletin Copyright © 2013 vBulletin Solutions, Inc.