4/23/2017

Virtual desctructor

We  have two classes

class A{

public :

A(){  cout<<”Base constructor of class A “;

~A(){  cout<<”Base destructor of class A “;

};

Class B : public A{

public :

B(){ cout<<”Derived constructor of class B” ;}

~B(){  cout<<”Derived desstructor of class B“};

};

 

Now in main , we have different way to create object;

int main(){

// Case 1 –> Object Creation

//Proper constructor and destructor will be called , nothing need to be done

A objA;

B objB ;

//Case 2—> Pointer with same class dynamic object

A *pA = new A;

B *pB = new B;

….

…..

delete pA ;delete pB; // no issue ,work properly and destructor of A & B class will be called

//Case 3 –> Base class pointer , derived class memory

//in such case , proper destructor will not be called

A *pBase = new B; ///constructor of B & A is called

---------

……..

delete pBase;   //Destructor of A is called

return 0;

}

Case 3 Output

Base constructor of class A

Derived  constructor of class B

Derived  Destructor of class B

---------------------------------------------------------------

Here Base class destructor is not called.

The only problem case is Base Class pointer with derived class memory.

while we assign the memory by statement A *pBase = new B;  compiler know that it will be B class , so proper constructor is called.

when we called delete pBase , it does not know which class memory it hold in run time. That s why we should have a mechanism so that system can call destructor of class B at run time.

to achieve the same , we need to create the destructor as virtual .Once we declare destructor as virtual system automatically delete proper memory & call the destructor of class B.

to resolve the issue of dynamic memory allocation of derived class in Base class pointer & avoid Memory leak , we need to have virtual destructor.

so we need to define the class like this

class A{

public :

A(){  cout<<”Base constructor of class A “;

virtual ~A(){  cout<<”Base destructor of class A “;

};

Class B : public A{

public :

B(){ cout<<”Derived constructor of class B” ;}

~B(){  cout<<”Derived desstructor of class B“};

};

int main(){

//Case 3 –> Base class pointer , derived class memory

 

A *pBase = new B; 

---------

……..

delete pBase;   //Destructor of A is called

return 0;

}

Case 3 Output

Base constructor of class A

Derived  constructor of class B

Derived  Destructor of class B

Base destructor of class A

4/22/2017

Pure Virtual Function,Abstract Class

 

--------------------------------------

Pure virtual ==> no definition in class 

Class A{

public :

int x ;

void SetData(int a)=0 ; ///Pure virtual function

}

We can not create object of class A.

A objA; //error

All classes which have at least 1 pure virtual function is called Abstract Class

These classes object can not be created.

These classes need to be derived and pure virtual function need to be redefined.

Class D : public B{

void SetData(int a){           //redefine pure virtual function in derived class

x= a ;

///other stufff

}

D objD ; //valid and Ok

Programming Basic--2

 

Programming means creating software

Software can be categorized in many way ..for Simplicity we think it is as

System Software

–> Include all Operating system (OS) development , drivers and OS utility

-> various OS are present , some of famous OS are

Windows by Microsoft

MAC –> by Apple

Linux –> open source community

Android—> Open source for mainly Mobile platform , by google

Application Software

–> All the application where user directly interact.

There are many categorization of application software

starting from

  1. basic utility
  2. small application like calculator ,notepad etc
  3. Server Client based desktop application
  4. Cross platform application which works on multiple OS (on Windows ,linux etc)
  5. Cross Platform(Hardware) application which works on ARM and X86 baord etc
  6. Mobile applications
  7. Enterprise application
  8. Native application (C++)
  9. Hybrid application
  10. Web application
  11. DTV based application

and many more…

There are different language and frameworks are being used to develop different kind of applications .Based on the requirement & nature of application ,several type of  language , tools and IDE are being selected

Some of the language/Framework are

Programming –> C, C++ , Java ,

Scripting->     Java Script , pearl ,

Framework-> .NET , weWidget , node.js ,Ruby on Rails etc ,MFC

 

In next we will check the difference  between languages and framework as well difference in programming and scripting language

4/17/2017

Programming The world of Infinity

 

Computer =Software + Hardware

 

Hardware –>> All things which you can touch like keyboard , mouse ,RAM etc

Two Major parts

1. Input –> Gives input to computer , Like Keyboard , Mouse ,Mike

2.Output-> Gives out from computer—> Printer , Speaker ,Display

 

Software –> Which you can not touch but play a major role (like your mind , your thoughts)

Software consist two major part

System Software –>> Operating System ,Drivers etc

Application Software –> Application software , paint ,MS Office , Photoshop etc

 

Why Programming Language :

For development of software

System Software and Application software are developed using various language ,reason is computer can understand only binary data

For human it is difficult to program in Binary, so there is a need of simpler language which human can work and which can be translated in computers language (Binary)

For the same reason there exist so many language like , C , C++ , Java ,Lua , JavaScript… etc.

Also , a lot of other language ,framework developed over the time to make it easier for work

4/28/2012

Mind ....Thinking and worry

Till this time in the earth , human mind is most powerful among all the known things .The best thing is that there is no limit of it .


Someone says if you can think it , it means you can do it.


Thinking is the first step .


Lot of people will say that the think a lot , but there is no outcome .They are more disturbed after thinking .So they do not want to think.


Every good thing also has some dark side .  If the Dark and Bright side is balanced , the life will be smooth .If not , then whole system will be dis-balanced.


Nature (Science or GOD whatever name u like) balance all this very well . From Sun , Moon earth roatation ,weather , life and death, young and old. man and women , Science and Religion, logic and love ,war and peace , Mountain and See , GOD and Shaitan, Haven and Hell  , almost everything has some balance .


There is nothing in the world without opposite . Sometime I feel that when the GOD is supreme then why in each religion there is story of demon  and GOD is always fighting with demon   (.but it exists ,almost in every religion)


Come to mind 


It can think , this is quality which diffrenitate it from other ,but when the thinking is negative it makes the people in trap.The thinking then turn into the worry and destroy the whole life .


Some people can argue ,why to think, no thinking ,no worry and no tension .


The thinking is positive and worry is negative . There is very thin line between these two.
If you are not thinking then there is no chance of being mad , the person who never think never became mad, but in nature , the animal also never became mad .(you can get exception ,that is due to other factor) .


The best part of human is to thinking power , if you are not using it , you are just equal to living being(animals).


Human can think for the reason of existence,reason for being    ,no one else can do in nature .


But when this thinking creates fear , this thinking propagate negativity in work and action ,that time it turns in worry. This is negative thinking ,destructive thinking .


Sometime there is confusion between these two . One reference is taken from GITA ,do the work , do not worry for the result .
 It was felt that do the work ,do the work  and so on .... do not worry , But it does not mean that do not do think before work/action . It can be in the way Think Work and Do Not Worry . 


if you do the action but how an action can be without purpose .If there is action then there was a  purpose.So think for the purpose ,do the action and then do not worry while doing action .


If in between the action you worried for the result , then the mind and energy will be disturbed and failure is guaranteed . When you are doing action , it should be focused not worried for the aftereffect 


But the issue is we are disturbed ,while doing one thing we think for others. In Temple we think for the office ,in office we think for the vacation and in vacation we think for work and progress. While relaxing , people think for the work and during work they feel sleep .This cycle is continue .


This is reason of many of the problem ,if not all .If while doing one work we are thinking for other our mind and body are divided and we can not enjoy ,we can not live the life at that moment, This relates to thing that people feel emptiness , they are not satisfied  .And finally they are worried all time .


Lot of books ,many Spiritual  gurus ,many master are telling to people Leave the worry,how to leave worry , stress free life etc etc . But it is only half truth , it is not about leaving worry , it is about thinking , if you will think then there is no worry , if you will not think , then there is no option ,you have to worry .


Thinking and Being in present , will make the people satisfied .


We have two option either do not think and live like animals .
Or 
Think , live consciously and Be Stress free .

4/25/2012

The Next is Mind

Coming to Indian philosophy which describe all living animal as well as all object in earth derived from one GOD.They differ only by there degree of consciousness of there mind and soul.

Science says that all animal are  different  from mental ability  and physical  looks. Even mental ability or mind is the most important .

Human mind is most developed among all animal , and this is the reason ,they can rule over others animal .

You can see nearby , all the developed mind are using less developed , Humans utilize animal .
More developed country use less developed ,advance society uses backward society  ,More minded people utilize less minded and so on the process continue till end . This loop is everywhere .


Human mind is most developed , but is there  any difference between an Animal mind or human Mind after death .In materialistic form both are same .Both are build from the same matter .


If you will cut the Head you can get the mind , but you can not get consciousness , you can not get the soul .


When science says that Human are most developed , it simply mean we have the mind which can think , we can learn easily , we can adopt , we can invent .This all is very fast .


Animal can not do it or if they can , the process is as slow its seems equal to null .


In philosophy or science everywhere the mind , the thinking capability make us different from others.


If someone says that , "If you can think it you can do it ". Simply it means  if you can not think, you can not it .For any thing to complete , any thing to start , thinking is the first steps.


This thinking/thought process make the Human different from animal .

Indians moved one step ahead ,they are saying though you have the most developed mind , but there is something that is above than that ,your consciousness . It can rule your mind .There is soul inside ,and that is above all. We can not see it , but we can feel it .They have there own logic behind this . 


Even the soul is same for all animal , it is from the same source , but the there soul is less awaken (not developed ,development is in science only) compare to  human.

They say that human soul is most awaken , as human mind. We can feel but the animal can not feel the soul.

We are human because we can think.


4/24/2012

Zero the starting

No One knows when the earth or our solar system created ,It is also not fixed from when the human exists, No one knows the history , everything is just an assumption .

 We can divide the complete theory between two main stream 


 1.Science 

2.Religion

Science define the life as an living object , it has the reason for everything , proof for most of the thing.Except the basic thing how the universe has started .

Its like defining the number system starting with zero which can not be defined it self. Zero as we define is the ultimate number , it has no value ,no size ,no parameter but it exists. It exist because this is the base of all our science ,we may have alternate number system but all will fail after a certain level,Only Decimal system gives us the power so that we can count up to infinity . How interesting this is , that we are making the things based on the zero which itself not exists.

The same is science ,If you will not ask for the reason of the creation  , all system will work for you .Every question is answered by it until you will not ask about the origin .

Science can define everything very well .It can give you the reason for every thing ,well defined satisfactory reason .It define How the things work , but it will never answer why the things work.Why there is origin ,it does not answer .


 Coming to Religion .

Start with Hindu , the oldest religion .From the early days of Vedas , its writer( *not creator)and reader are looking for the meaning of life .From all Veda ,Purana,Gita etc everything bind us towards some self incarnated  GOD and then define every object living or dead as a part of that or creation of that . Different sects give different name but all gives the same theory that there was one supreme person , who created the world .

 Christianity and Islam , the other two major religion also refer at least one Initial reference , they all say that there is a GOD , who created the universe . Interestingly all religion will give the same answer ,there is a GOD who created everything , but why that GOD exists no one speaks.

Hindus have a ultimate theory , that every living object is part of that GOD,which is not common in other religion , By this way they define that all living animal and human are equivalent on root level .They are the part of same GOD and all living object has the same soul .There is no difference between soul of an animal and soul of a man . There mythology says that anyone can be incarnated as other(Man to animal and reverse). The only difference between soul of an animal and human is the difference between their consciousness .

 This relate the same theory of science , which says that humans are developed animal :) . There is no difference between an man and animal , most of the things are the same . From birth ,food , digestion system , blood system ,reproduction and finally death most of the things are common .

 Many of you will be shocked , what I want to say . Its difficult to think that we are animal ,just developed animal . 

But if we follow the science or we follow the Hindu religion they suggest that all our base is same. While science talks of the body , the material things ,Religion talks for the soul , the invisible part. Even Christianity and Islam all define a base GOD (like Zero ) and derive everything from that. But the main question is unanswered ,why GOD ?

 We require zero because without that our system will not work .So for science to work there should be zero. Similarly for religion to work there should be some starting point, and that is Ishwar( GOD).

 Once zero came in existence ,like GOD , we can define everything with reference from that So we came to Human now , Science and religion both says that man are the most developed animal .The only thing which differentiate Human from animal is the Mind. Mind is the only thing that makes us Human .That make us different from rest of the world. No animal , nothing is as powerful as an Human mind in the world.

GOD is like zero of science ,in religion  . No value, No size , No parameter but it exist .
Without that nothing will work .

Let us move one step ahead , Most of us are agree that the best part of the Human is mind. Just think about the Human without mind. If a persons mind is not working , then there is not such characteristic which can separate that person with animals .

This is the mind , based on which Animals and man are differentiated