<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7906724269893492858</id><updated>2024-09-05T20:08:54.856-07:00</updated><category term="Linux"/><category term="C/C++"/><category term="CMOS"/><category term="Hardware"/><title type='text'>My Programming Guide</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-1540122856060885570</id><published>2011-06-09T06:35:00.000-07:00</published><updated>2011-06-09T06:46:19.345-07:00</updated><title type='text'>How to Initialize const member variable? or What is Initialization Lists?</title><content type='html'>In C++, Memory will be allocated for all member variables of a class even before the constructor of that class is getting called. So we can&#39;t initialize a &lt;span style=&quot;font-weight: bold;&quot;&gt;const &lt;/span&gt;member variable inside a class constructor.&lt;br /&gt;&lt;br /&gt;It can be initialized as in the below example using initialization list.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// Sample.cpp : Defines the entry point for the console application.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#008000;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;#include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;#include&lt;/span&gt; &amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color:#0000ff;&quot;&gt;namespace&lt;/span&gt; std;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;class&lt;/span&gt; CTriangle&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;public&lt;/span&gt;:&lt;br /&gt;CTriangle();&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color:#0000ff;&quot;&gt;float&lt;/span&gt; m_fPi;&lt;br /&gt;};&lt;br /&gt;CTriangle::CTriangle():m_fPi(3.14)&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;color:#008000;&quot;&gt;//constructor&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;int&lt;/span&gt; main()&lt;br /&gt;{&lt;br /&gt;CTriangle obj;&lt;br /&gt;cout&amp;lt;&amp;lt;obj.m_fPi;&lt;br /&gt;&lt;br /&gt;getch();&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;return&lt;/span&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/1540122856060885570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/06/how-to-initialize-const-member-variable.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/1540122856060885570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/1540122856060885570'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/06/how-to-initialize-const-member-variable.html' title='How to Initialize const member variable? or What is Initialization Lists?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-6174531472717565019</id><published>2011-02-15T06:03:00.000-08:00</published><updated>2011-02-15T06:09:19.393-08:00</updated><title type='text'>What is deep copy constructor?</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;What is deep copy constructor?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Overriding default copy constructor with a constructor which copies all the members including all dynamically allocated members is called deep copy constructor.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;CODE&gt;&lt;PRE&gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;string&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;using&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;namespace&lt;/FONT&gt; std;&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;class&lt;/FONT&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;public&lt;/FONT&gt;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student(&lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt;* szName,&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; nAge)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_szName =&lt;FONT COLOR=&quot;#0000ff&quot;&gt;new&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt;[20];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(m_szName,szName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   Student(&lt;FONT COLOR=&quot;#0000ff&quot;&gt;const&lt;/FONT&gt; Student &amp;amp;obj )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_szName =&lt;FONT COLOR=&quot;#0000ff&quot;&gt;new&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt;[20];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(m_szName,obj.m_szName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=obj.m_nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ~Student()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;delete&lt;/FONT&gt;[] m_szName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_szName=NULL;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Memory destroyed \r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; m_nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt; *m_szName;&lt;br /&gt;};&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student *ptr=&lt;FONT COLOR=&quot;#0000ff&quot;&gt;new&lt;/FONT&gt; Student(&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;John&quot;&lt;/FONT&gt;,12);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;ptr-&amp;gt;m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; ptr-&amp;gt;m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj( *ptr);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;obj.m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; obj.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#008000&quot;&gt;//obj scope ends and ~Student() will be called&lt;/FONT&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;ptr-&amp;gt;m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; ptr-&amp;gt;m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;delete&lt;/FONT&gt; ptr;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;return&lt;/FONT&gt; 0;&lt;br /&gt;}&lt;/PRE&gt;&lt;/CODE&gt;&lt;br /&gt;Result:&lt;br /&gt;&lt;br /&gt;Name: John&lt;br /&gt;Age: 12&lt;br /&gt;Name: John&lt;br /&gt;Age: 12&lt;br /&gt;Memory destroyed&lt;br /&gt;Name: John&lt;br /&gt;Age: 12&lt;br /&gt;Memory destroyed</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/6174531472717565019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-deep-copy-constructor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/6174531472717565019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/6174531472717565019'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-deep-copy-constructor.html' title='What is deep copy constructor?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-6006697240765687787</id><published>2011-02-15T01:36:00.001-08:00</published><updated>2011-02-15T06:09:44.095-08:00</updated><title type='text'>What is shallow copy?</title><content type='html'>&lt;b&gt;What is shallow copy?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Default copy constructor of compiler copies all the member variables&lt;br /&gt;from source to destination object. This is called shallow copy&lt;br /&gt;constructor.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;CODE&gt;&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;string&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;using&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;namespace&lt;/FONT&gt; std;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;class&lt;/FONT&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;public&lt;/FONT&gt;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student(&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; nAge)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; m_nAge;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;};&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj(13);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age1: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; obj.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj1(obj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age2: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;obj1.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;return&lt;/FONT&gt; 0;&lt;br /&gt;}&lt;/PRE&gt;&lt;br /&gt;&lt;/CODE&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;Age1: 13&lt;br /&gt;Age2: 13&lt;br /&gt;&lt;br /&gt;Example 2:&lt;br /&gt;&lt;CODE&gt;&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;string&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;using&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;namespace&lt;/FONT&gt; std;&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;class&lt;/FONT&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;public&lt;/FONT&gt;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student(&lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt;* szName,&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; nAge)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_szName =&lt;FONT OLOR=&quot;#0000ff&quot;&gt;new&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt;[20];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(m_szName,szName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ~Student()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;delete&lt;/FONT&gt;[] m_szName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_szName=NULL;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Memory destroyed \r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; m_nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt; *m_szName;&lt;br /&gt;};&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student *ptr=&lt;FONT COLOR=&quot;#0000ff&quot;&gt;new&lt;/FONT&gt; Student(&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;John&quot;&lt;/FONT&gt;,12);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;ptr-&amp;gt;m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; ptr-&amp;gt;m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj( *ptr);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;obj.m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; obj.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#008000&quot;&gt;//obj scope ends and ~Student() will be called&lt;/FONT&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#008000&quot;&gt;//Will Crash here&lt;/FONT&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#008000&quot;&gt;//because m_szName is already freed in destructor.&lt;/FONT&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#008000&quot;&gt;// this is the problem with shallow copy&lt;/FONT&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;ptr-&amp;gt;m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; ptr-&amp;gt;m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;delete&lt;/FONT&gt; ptr;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;return&lt;/FONT&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;&lt;/CODE&gt;&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;Crash!!!!!!!!!!!&lt;/b&gt;&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/6006697240765687787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-shallow-copy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/6006697240765687787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/6006697240765687787'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-shallow-copy.html' title='What is shallow copy?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-4270364328152687222</id><published>2011-02-15T00:12:00.001-08:00</published><updated>2011-02-15T00:18:15.429-08:00</updated><title type='text'>What is copy constructor?</title><content type='html'>&lt;b&gt;What is copy constructor?&lt;/b&gt;&lt;br /&gt;In addition to providing a default constructor and a destructor, the compiler also provides a default copy constructor which is called each time a copy of an object is made. When a program passes an object by value, either into the function or as a function return value, a temporary copy of the object is made. This work is done by the copy constructor.&lt;br /&gt;&lt;br /&gt;All copy constructors take one argument or parameter which is the reference to an object of the same class. The default copy constructor copies each data member from the object passed as a parameter to the data member of the new object.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;CODE&gt;&lt;br /&gt;&lt;PRE&gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;string&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;using&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;namespace&lt;/FONT&gt; std;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;class&lt;/FONT&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;public&lt;/FONT&gt;:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student()&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Default constructor\r\n&quot;&lt;/FONT&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student(&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; nAge)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Overloaded Constructor Called \r\n&quot;&lt;/FONT&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=nAge;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student(Student &amp;amp;a)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Copy constructor\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge = a.m_nAge;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; m_nAge;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; main()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj(13);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; obj.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj1(obj);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;obj1.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;return&lt;/FONT&gt; 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;&lt;br /&gt;&lt;/CODE&gt;&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;&lt;br /&gt;Overloaded Constructor Called&lt;br /&gt;Age: 13&lt;br /&gt;Copy constructor&lt;br /&gt;Age: 13</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/4270364328152687222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-copy-constructor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/4270364328152687222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/4270364328152687222'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-copy-constructor.html' title='What is copy constructor?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-1796309639516784815</id><published>2011-02-14T02:35:00.001-08:00</published><updated>2011-02-14T02:35:23.772-08:00</updated><title type='text'>Can destructor be overloaded?</title><content type='html'>&lt;b&gt;Can destructor be overloaded?&lt;/b&gt;&lt;div&gt;&lt;br /&gt;A destructor can never be overloaded. An overloaded destructor would mean that the destructor has taken arguments. Since a destructor does not take arguments, it can never be overloaded.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/1796309639516784815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/can-destructor-be-overloaded.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/1796309639516784815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/1796309639516784815'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/can-destructor-be-overloaded.html' title='Can destructor be overloaded?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-6596512682507587224</id><published>2011-02-14T02:19:00.000-08:00</published><updated>2011-02-14T02:34:12.794-08:00</updated><title type='text'>What is destructor?</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;What is destructor?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A destructor is a special function member of a class that is automatically called when an object about to be deleted. It always has the same name as the class preceded by a ‘tilt’ ~ symbol and has no return type. It is used to free allocated memory used by an object. It takes no arguments.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;CODE&gt; &lt;br /&gt;&lt;PRE&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;string&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;using&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;namespace&lt;/FONT&gt; std;&lt;br /&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;class&lt;/FONT&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;public&lt;/FONT&gt;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student(&lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt;* szName,&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; nAge)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_szName =&lt;FONT COLOR=&quot;#0000ff&quot;&gt;new&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt;[20];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(m_szName,szName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ~Student()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;delete&lt;/FONT&gt;[] m_szName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_szName=NULL;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Memory destroyed \r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; m_nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt; *m_szName;&lt;br /&gt;};&lt;br /&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj(&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Raj&quot;&lt;/FONT&gt;,13);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;obj.m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; obj.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student *ptr=&lt;FONT COLOR=&quot;#0000ff&quot;&gt;new&lt;/FONT&gt; Student(&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;John&quot;&lt;/FONT&gt;,12);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;ptr-&amp;gt;m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; ptr-&amp;gt;m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;delete&lt;/FONT&gt; ptr;&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;return&lt;/FONT&gt; 0;&lt;br /&gt;}&lt;/PRE&gt; &lt;br /&gt;&lt;/CODE&gt; &lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;Name: Raj&lt;br /&gt;Age: 13&lt;br /&gt;Memory destroyed&lt;br /&gt;Name: John&lt;br /&gt;Age: 12&lt;br /&gt;Memory destroyed</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/6596512682507587224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-destructor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/6596512682507587224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/6596512682507587224'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-destructor.html' title='What is destructor?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-6011411679577768061</id><published>2011-02-14T02:06:00.001-08:00</published><updated>2011-02-14T02:17:11.504-08:00</updated><title type='text'>What is overloaded constructor?</title><content type='html'>&lt;b&gt;What is overloaded constructor?&lt;/b&gt;&lt;br /&gt;An overloaded constructor is a constructor which takes arguments. It is also called parameterized constructor.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;CODE&gt; &lt;br /&gt;&lt;PRE&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;string&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;using&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;namespace&lt;/FONT&gt; std;&lt;br /&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;class&lt;/FONT&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;public&lt;/FONT&gt;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(m_szName,&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;&quot;&lt;/FONT&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student(&lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt;* szName,&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; nAge)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(m_szName,szName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; m_nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt; m_szName[20];&lt;br /&gt;};&lt;br /&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; main()&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;obj.m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; obj.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj2(&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;John&quot;&lt;/FONT&gt;,12);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;obj2.m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; obj2.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;return&lt;/FONT&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;/PRE&gt; &lt;br /&gt;&lt;/CODE&gt; &lt;br /&gt;Result:&lt;br /&gt;&lt;br /&gt;Name:&lt;br /&gt;Age: 0&lt;br /&gt;&lt;br /&gt;Name: John   &lt;br /&gt;Age: 12</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/6011411679577768061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-overloaded-constructor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/6011411679577768061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/6011411679577768061'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-overloaded-constructor.html' title='What is overloaded constructor?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-5702493931724046217</id><published>2011-02-13T04:57:00.000-08:00</published><updated>2011-02-14T02:17:23.404-08:00</updated><title type='text'>What is constructor?</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;What is constructor?&lt;/span&gt;&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;A constructor is a class function with the same name as the class itself. It cannot have a return type and may accept parameters. It will be called after the memory allocation to the member variables. Constructor is used to set initial values to members variables.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;CODE&gt; &lt;br /&gt;&lt;PRE&gt; &lt;br /&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;string&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;#include&lt;/FONT&gt; &amp;lt;conio.h&amp;gt;&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;using&lt;/FONT&gt; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;namespace&lt;/FONT&gt; std;&lt;br /&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;class&lt;/FONT&gt; Student&lt;br /&gt;{&lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;public&lt;/FONT&gt;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_nAge=0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(m_szName,&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;&quot;&lt;/FONT&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; m_nAge;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;char&lt;/FONT&gt; m_szName[20];&lt;br /&gt;};&lt;br /&gt; &lt;br /&gt;&lt;FONT COLOR=&quot;#0000ff&quot;&gt;int&lt;/FONT&gt; main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Student obj;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Name: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt;obj.m_szName&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;Age: &quot;&lt;/FONT&gt;&amp;lt;&amp;lt; obj.m_nAge&amp;lt;&amp;lt;&lt;FONT COLOR=&quot;#ff0000&quot;&gt;&quot;\r\n&quot;&lt;/FONT&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT COLOR=&quot;#0000ff&quot;&gt;return&lt;/FONT&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;/PRE&gt; &lt;br /&gt;&lt;/CODE&gt; &lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;Name:   &lt;br /&gt;Age: 0</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/5702493931724046217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-constructor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/5702493931724046217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/5702493931724046217'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/what-is-constructor.html' title='What is constructor?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-8707298619320715053</id><published>2011-02-13T04:51:00.000-08:00</published><updated>2011-02-13T04:55:40.476-08:00</updated><title type='text'>Difference between C and C++?</title><content type='html'>&lt;b&gt;Difference between C and C++?&lt;/b&gt;&lt;br /&gt;C is a structured programming language. C++ is object oriented programming language.&lt;br /&gt;&lt;br /&gt;Programmers use functions/procedures to deal with larger program in C language. In C++ programmers construct a class and related member functions to deal with large class functionality.&lt;br /&gt;&lt;br /&gt;C++ can have member functions of structures/classes. C does not support modularization of member functions.&lt;br /&gt;&lt;br /&gt;C++ can hide/abstract member variables/functions by private or protected keyword. In C language structure members can not be hidden from outside world. C never support abstraction.&lt;br /&gt;&lt;br /&gt;C++ has function and operator overloading/polymorphism feature. C language does not have polymorphism features.&lt;br /&gt;&lt;br /&gt;C also does not support inheritance.</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/8707298619320715053/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/difference-between-c-and-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/8707298619320715053'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/8707298619320715053'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2011/02/difference-between-c-and-c.html' title='Difference between C and C++?'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-7631319921186826363</id><published>2010-07-17T05:17:00.000-07:00</published><updated>2011-02-13T04:43:46.206-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C/C++"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>My First c++ program in Linux</title><content type='html'>Using any Text editor in Linux type the following program.For help refer&lt;div&gt;&lt;a href=&quot;http://mycomputercodes.blogspot.com/2010/07/my-first-c-programming-in-linux.html&quot;&gt;http://mycomputercodes.blogspot.com/2010/07/my-first-c-programming-in-linux.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;pre&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;#include&lt;/span&gt;&amp;lt;iostream&amp;gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;namespace&lt;/span&gt; std;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt; main(){&lt;br /&gt;cout&amp;lt;&amp;lt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&quot;Hello world&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt; 1;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To Compile type the following command&lt;br /&gt;g++ sample.cpp -o sample&lt;br /&gt;To run type the following command&lt;br /&gt;./sample&lt;br /&gt;&lt;pre&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7P8dadKY5UYuTR4NA86Sh3MVdFwaug-sLbXCu_U0iR4qAzO_8d365fCJrl8IP8QoDaX9pPuR6riTf44rhnyj26qjquByz-I9h1Vs7XiNfTQjSvd44wMzRTWSy9qpBkPbPMZqp33AdA4c/s1600/cpp-UbuntuLinux.png&quot;&gt;&lt;img style=&quot;display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 370px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7P8dadKY5UYuTR4NA86Sh3MVdFwaug-sLbXCu_U0iR4qAzO_8d365fCJrl8IP8QoDaX9pPuR6riTf44rhnyj26qjquByz-I9h1Vs7XiNfTQjSvd44wMzRTWSy9qpBkPbPMZqp33AdA4c/s400/cpp-UbuntuLinux.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5494859995119433138&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;If you don&#39;t have g++ compiler you will get err or as in screenshot.&lt;br /&gt;then you may need to install g++ compiler.&lt;br /&gt;For install become super user as in&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;http://mycomputercodes.blogspot.com/2010/07/root-user-account-in-ubuntu-linux.html&quot;&gt;http://mycomputercodes.blogspot.com/2010/07/root-user-account-in-ubuntu-linux.html&lt;/a&gt;&lt;br /&gt;using &quot;su&quot; command&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;To install type following command in terminal:&lt;br /&gt;&lt;br /&gt;apt-get install g++&lt;br /&gt;&lt;br /&gt;It will automatically  download and install from Intern et.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Otherwise we can download&lt;br /&gt;Code::Block IDE for compiling and running c++ program.&lt;br /&gt;&lt;pre&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIdXPu5qvclnEhMzutDg7T2se-cs7vwFP9eZczmlkB1WFjwDCGCMvaHehM36OuPXacueW6o3oaSBNX3JlzmPRaVKzCh4bs7rKSns0-I914eqEgICehbRIrRzpr_ciqYbRVjUBr8wldMLE/s1600/codeblocks.png&quot;&gt;&lt;img style=&quot;display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 187px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIdXPu5qvclnEhMzutDg7T2se-cs7vwFP9eZczmlkB1WFjwDCGCMvaHehM36OuPXacueW6o3oaSBNX3JlzmPRaVKzCh4bs7rKSns0-I914eqEgICehbRIrRzpr_ciqYbRVjUBr8wldMLE/s400/codeblocks.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5494860493324314914&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;for that type following command as in screen shot:&lt;br /&gt;apt-get install codeblocks&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcF_QS2o3xDRUIdoguzvyUkJMFiE5Av7KuQ553J_l3YQVz7XQWsPFdTE3uOnWHBIOuE-JSyvkf5RV1ApaZ8WQFV9YSJoSU3d59G0nFSdhxudN6B2LKDfbDbMk2meJUNhyD4FrtKu3jCEg/s1600/codeblocks.png&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyfr3OPQme4o4nYWJz62WIY0uWN6umitdAokn64F3lOIhe0Yn8rUisZjdyBHseDBl3wvJezzOJwFZkY6Fb8loPDxXdwVJjxoHVcwaed3Y3UxWG_6uHX5yP58RC9_3xE-bAPkjrNuMnmZw/s1600/Screenshot-sample.cpp+-+Code::Blocks+8.02.png&quot;&gt;&lt;img style=&quot;display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 203px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyfr3OPQme4o4nYWJz62WIY0uWN6umitdAokn64F3lOIhe0Yn8rUisZjdyBHseDBl3wvJezzOJwFZkY6Fb8loPDxXdwVJjxoHVcwaed3Y3UxWG_6uHX5yP58RC9_3xE-bAPkjrNuMnmZw/s400/Screenshot-sample.cpp+-+Code::Blocks+8.02.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5494858187453628578&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/7631319921186826363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2010/07/my-first-c-program-in-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/7631319921186826363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/7631319921186826363'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2010/07/my-first-c-program-in-linux.html' title='My First c++ program in Linux'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7P8dadKY5UYuTR4NA86Sh3MVdFwaug-sLbXCu_U0iR4qAzO_8d365fCJrl8IP8QoDaX9pPuR6riTf44rhnyj26qjquByz-I9h1Vs7XiNfTQjSvd44wMzRTWSy9qpBkPbPMZqp33AdA4c/s72-c/cpp-UbuntuLinux.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-4578017218477927593</id><published>2010-07-17T04:44:00.000-07:00</published><updated>2011-02-13T04:40:48.607-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>root user account in Ubuntu Linux</title><content type='html'>After installing Ubuntu Linux, I tried to install some softwares, but i don&#39;t have &quot;Super user&quot; or Administrator privileges. I know in some Linux &quot;root&quot; user like administrator account in Windows.  I tried but i don&#39;t have have any user with name &quot;root&quot;.&lt;br /&gt;&lt;br /&gt;Then i found, the user I created when installing Linux itself a  super user account.&lt;br /&gt;Whenever I need Administrator privileges I need to use &lt;span style=&quot;font-weight: bold;&quot;&gt;&quot;su&quot;&lt;/span&gt; command in Terminal to become super user.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7tYEYg7HmwO0AzXKAA94QAm7gRlSDJIq2FXC0wxsGTEL62K9o-tNZvWjsESvq341NQbhveS2Or5wXL4azyVTGhQpBYhJelPvtWVnVdmVeljpcp1fFgPrxNkE_c-yS6HA5tV9HegOkuMA/s1600/root-user.png&quot;&gt;&lt;img style=&quot;float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 320px; height: 156px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7tYEYg7HmwO0AzXKAA94QAm7gRlSDJIq2FXC0wxsGTEL62K9o-tNZvWjsESvq341NQbhveS2Or5wXL4azyVTGhQpBYhJelPvtWVnVdmVeljpcp1fFgPrxNkE_c-yS6HA5tV9HegOkuMA/s320/root-user.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5494847970365962466&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/4578017218477927593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2010/07/root-user-account-in-ubuntu-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/4578017218477927593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/4578017218477927593'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2010/07/root-user-account-in-ubuntu-linux.html' title='root user account in Ubuntu Linux'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7tYEYg7HmwO0AzXKAA94QAm7gRlSDJIq2FXC0wxsGTEL62K9o-tNZvWjsESvq341NQbhveS2Or5wXL4azyVTGhQpBYhJelPvtWVnVdmVeljpcp1fFgPrxNkE_c-yS6HA5tV9HegOkuMA/s72-c/root-user.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-3268383390784759200</id><published>2010-07-01T12:57:00.000-07:00</published><updated>2011-02-13T04:40:48.614-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>My first C Programming in Linux</title><content type='html'>I am good in C, C++ programming in windows using visual studio editor, but I don&#39;t know how to write,  compile and run a C, C++ program in Linux. Just I learned. I like to share that with all.&lt;br /&gt;&lt;br /&gt;Open any editor like vi and create a file &quot;hello.c&quot; and write a simple hello world program.&lt;br /&gt;To create a file in using VI editor.&lt;br /&gt;Open Terminal window then type following command to create a file.&lt;br /&gt;vi hello.c&lt;br /&gt;Now press the insert key and type the following program.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;#include&lt;/span&gt;&amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt; main()&lt;br /&gt;{&lt;br /&gt;printf(&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&quot;hello world&quot;&lt;/span&gt;);&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt; 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;now press type following command to save and exit&lt;br /&gt;:wq&lt;br /&gt;To Compile type the following command&lt;br /&gt;cc hello.c -o hello&lt;br /&gt;To run type the following command&lt;br /&gt;./hello</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/3268383390784759200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2010/07/my-first-c-programming-in-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/3268383390784759200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/3268383390784759200'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2010/07/my-first-c-programming-in-linux.html' title='My first C Programming in Linux'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7906724269893492858.post-4818628961994106175</id><published>2010-07-01T11:32:00.000-07:00</published><updated>2011-02-13T04:40:48.621-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CMOS"/><category scheme="http://www.blogger.com/atom/ns#" term="Hardware"/><title type='text'>I Can&amp;#39;t able to Access HTTPS website</title><content type='html'>Once I had a problem in accessing all https website like online banking websites, gmail, from my PC with Windows XP. But i can able to access all other wesites. I thought some virus or spyware may got installed. I checked with different Anti-virus scanner, but I can&#39;t able to find any thing. Then I checked &quot;host&quot; file in  &quot;c:\windows\system32\drivers\etc\&quot; path, there also i didn&#39;t find any problem.&lt;br /&gt;&lt;br /&gt;At last I found the problem, This happend for me all because of CMOS battery failure.&lt;br /&gt;When CMOS battery failed, I used to press F1 to continue loading in default settings.&lt;br /&gt;So my system got set very very old date and time.Then I set the correct date . So problem solved and now I can able to access all https websites.</content><link rel='replies' type='application/atom+xml' href='http://mycomputercodes.blogspot.com/feeds/4818628961994106175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mycomputercodes.blogspot.com/2010/07/i-can-able-to-access-https-website.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/4818628961994106175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7906724269893492858/posts/default/4818628961994106175'/><link rel='alternate' type='text/html' href='http://mycomputercodes.blogspot.com/2010/07/i-can-able-to-access-https-website.html' title='I Can&amp;#39;t able to Access HTTPS website'/><author><name>Coder</name><uri>http://www.blogger.com/profile/08192730023918900936</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>