Posts

Showing posts from 2014

Pointers in C.

Best documents for Pointers in C. This document will make life easier for those who thinks "Pointer: A difficult Topic".  https://docs.google.com/file/d/0Bz7eXe9Jx0skOWFkTW1CS2lEUWs/preview

C++ Program : How to Prevent an object being created on Stack.

// We can even make constructor of a class as private, not to create object on stack. // But constructor has many variants. like constructor with no argument, constructor with arguments. // So, we made destructor as private. Because Destructor will be only one per class. // Prevent Creating Object on Stack // Declare Destructor of a class as Private/Protected. #include<iostream> using namespace std; class base {     public:         base(int a)         {             cout<<"Parameter Constructor\n";         }         base()         {             cout<<"Constructor\n";         }            void destroy()         {             delete this;         }     private:         ~base(); }; base::~base() {     cout<<"Destructor\n"; } int main() {     base *b = new base(10);;     b->destroy();     base *bb = new base; }