<?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: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-3202817326633385344</id><updated>2011-11-27T16:29:39.260-08:00</updated><category term='OOPS'/><category term='Basics Of C++'/><category term='C vs C++'/><title type='text'>Learning C++</title><subtitle type='html'>Learning C++ is a fantastic programming experience.Objective of this webpage is to teach C++ to beginners in a simple manner and share knowledge of Object Oriented Programming Language Techniques.       
HAPPY LEARNING!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-1557265892014488267</id><published>2009-09-05T02:49:00.000-07:00</published><updated>2009-09-05T05:12:45.558-07:00</updated><title type='text'>Operator Overloading</title><content type='html'>&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;It is a wonderful feature of C++ through which we can provide different meaning to the operators such as +,-,=,== etc. Operators have different implementation according to requirement.&lt;br /&gt;&lt;br /&gt;As you know that operator can be used in mathematical expressions:&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;int i = j + 18;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;float x = y*1.5;&lt;br /&gt;&lt;br /&gt;Now it would be great if we could use such kind of operations with Objects. For example, If should be able to join or concatenate two Strings by using + operator.  Is it possible? Yes you can! That's what Operator Overloading for.&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;String first_name = "Amitabh";&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;String last_name = "Bachchan";&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Now if we want to concatenate both String into one. C++ should allow to do it. like :&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;String full_name = first_name+last_name;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Its absolutely fine. It can be done successfully. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;But, What about user-defined classes? Can this concept is applicable to them also? &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Let us take two user-defined date objects;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Class Time {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;int hours;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;int minutes;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;int seconds;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;. . . .&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;. . . . &lt;/span&gt;&lt;/div&gt;&lt;div&gt;Create objects of class Time :-&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;. . . .&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;    &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Time time1, time2;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Time time3 = time1 + time2; //(Its 100% valid.)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;time3++; // (this too...)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;. . . .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;. . . .&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;So, we can say that objective of Operator overloading is to provide experience of primitive data type with user defined datatype. Like this :&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;table bg="" style="color:0066CC;"&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table class="Apple-style-span"   style="  white-space: pre; font-family:-webkit-monospace;font-size:13px;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Primitive Data type&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;User Defined Data type&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;int num1,num2;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Time time1,time2;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;b&gt;int num3=num1+num2;&lt;/b&gt; &lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class="Apple-style-span"  style=" font-style: normal; font-weight: normal; font-family:Georgia;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;i&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;T&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;i&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;ime &lt;span class="Apple-style-span"  style=" font-style: normal; font-family:Georgia;"&gt;&lt;span class="Apple-style-span"  style=" font-style: italic; font-family:'courier new';"&gt;time3=time1+time2;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;num3++;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;&lt;span class="Apple-style-span"  style=" font-style: normal; font-weight: normal; font-family:Georgia;"&gt;&lt;i&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;time3++;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;hr color="orange"&gt;&lt;br /&gt;Some Points to REMEMBER : -&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;New oprators can not be created. Functionality of built-in operators can be modified.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Not all the operators can be overloaded.There are few which can not be overloaded.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;hr color="orange"&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal; "&gt;In C++, about 40 predefined opertors can be overloaded. The operator which can not be overloaded are as follows : &lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "&gt;&lt;b&gt;::&lt;/b&gt;,  &lt;b&gt;.&lt;/b&gt; ,  &lt;b&gt;.*&lt;/b&gt;,  &lt;b&gt;sizeof&lt;/b&gt; , &lt;b&gt;?:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "&gt;&lt;b&gt;&lt;i&gt;We can not overload preprocessing symbols like # and ###.&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: right;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;i&gt;To be continued.....&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-1557265892014488267?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/1557265892014488267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=1557265892014488267' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/1557265892014488267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/1557265892014488267'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2009/09/operator-overloading.html' title='Operator Overloading'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-4434514281534382766</id><published>2008-11-30T09:16:00.000-08:00</published><updated>2008-11-30T09:19:53.148-08:00</updated><title type='text'>Function Overloading 2</title><content type='html'>&lt;span style="font-weight:bold;"&gt;How to call Overloaded Functions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;printMe(108);&lt;br /&gt;printMe(3.14F);    &lt;br /&gt;printMe(420.12009);&lt;br /&gt;printMe(‘k’);&lt;br /&gt;&lt;br /&gt;Note :  suffix F or f has to be used with float without F or f it will be treated as double&lt;br /&gt;&lt;br /&gt;Function Overloading and Ambiguity &lt;br /&gt;&lt;br /&gt;If  compiler is not able to choose between two or more overloaded function , it leads to ambiguity. Ambiguous statements are errors and programs containing ambiguity will not compile.&lt;br /&gt;Main cause of ambiguity is C++’s automatic type conversions.&lt;br /&gt;C++ automatically attempts to convert the arguments used to call a function into the type of arguments expected by the function.&lt;br /&gt;&lt;br /&gt;For example:&lt;br /&gt;Suppose if function declration is &lt;br /&gt;int showMe(double d);&lt;br /&gt;&lt;br /&gt;and if we call it like&lt;br /&gt;&lt;br /&gt;showMe(‘x’); // not an error , conversion occurred&lt;br /&gt;&lt;br /&gt;So above statement will not show any error because C++ automatically converts the character ‘x’ into its double equivalent. &lt;br /&gt;&lt;br /&gt;Now consider this program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;iostream.h&gt;&lt;br /&gt;&lt;br /&gt;float exposeMe(float f);&lt;br /&gt;double exposeMe(double d);&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;    cout&lt;&lt;”Secret no : “&lt;&amp;lt;exposeMe(42.4); // not ambiguous, calls exposeMe( double) : 1&lt;br /&gt;    cout&lt;&lt;”\nAnother Secret number : “&lt;&amp;lt; exposeMe(100); // : 2&lt;br /&gt;     return 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;float exposeMe(float f)&lt;br /&gt;{&lt;br /&gt; return f;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;double exposeMe(double d)&lt;br /&gt;{&lt;br /&gt; return d;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Here, &lt;span style="font-weight:bold;"&gt;exposeMe()&lt;/span&gt; is overloaded it can accept either float or double type data. In 1  &lt;span style="font-weight:bold;"&gt;exposeMe(double)&lt;/span&gt; is called, because all floating point constants in C++ are automatically of type double if suffix f or F is not there. Hence this call is not ambiguous. However function 2 &lt;span style="font-weight:bold;"&gt;exposeMe(100)&lt;/span&gt; is called , it leads  to ambiguity because compiler has no way to know whether it should be converted to a float or to a double. This causes an error message to be displayed , and the program will not compile.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Another example of ambiguity &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;&lt;br /&gt;#include &lt;iostream.h&gt;&lt;br /&gt;&lt;br /&gt;float exposeMe(unsigned char c);&lt;br /&gt;double exposeMe(char c);&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;    cout&lt;&lt;”Reveled Character is  : “&lt;&amp;lt;exposeMe(‘x’);&lt;br /&gt;    cout&lt;&lt;”\nAnother Reveled Character is  : “&lt;&amp;lt; exposeMe(999); // : 2&lt;br /&gt;    return 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;float exposeMe(unsigned char c)&lt;br /&gt;{&lt;br /&gt; return c - 1;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;double exposeMe(char c)&lt;br /&gt;{&lt;br /&gt; return c + 1;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;In C++, unsigned char and char are not inherently ambiguous. However, when exposeMe(99) is called the compiler has no way to know which function to call. That is, whether  99 should be converted into a char or an unsigned char?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To be continued….&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-4434514281534382766?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/4434514281534382766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=4434514281534382766' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/4434514281534382766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/4434514281534382766'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2008/11/function-overloading-2.html' title='Function Overloading 2'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-8000588632555970823</id><published>2008-11-30T09:00:00.000-08:00</published><updated>2008-11-30T09:15:42.154-08:00</updated><title type='text'>Function Overloading</title><content type='html'>‘Overloading’ means a thing is having one name but distinct meanings. C++ supports two types of overloading&lt;br /&gt;1. Function Overloading&lt;br /&gt;2. Operator Overloading&lt;br /&gt;&lt;br /&gt;Function overloading means one function name can have different meanings. And it can perform distinct tasks. But now the question is, how it can be done ?&lt;br /&gt;It is done very intelligently, just providing different argument lists which is also known as function signature. The overloaded function is selected on the basis of following criteria –&lt;br /&gt; Number of arguments&lt;br /&gt; Type of arguments&lt;br /&gt; Order of arguments&lt;br /&gt;&lt;br /&gt;Important : - return type of function doesn’t take participate in overloading.&lt;br /&gt;&lt;br /&gt;This information is available to compiler at compile-time itself , hence called early binding or static binding or static linking. It is also known as Compile-time polymorphism.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For example :&lt;br /&gt; A. float sum ( int a, int b)&lt;br /&gt; B. float sum (float a, float b)&lt;br /&gt; C. float sum (float a, float b, float c)&lt;br /&gt;&lt;br /&gt;That is , in A sum() is taking two int arguments , in B sum is taking two float arguments while in C sum() is taking three float arguments.&lt;br /&gt;&lt;br /&gt;Declaration and Definition&lt;br /&gt;&lt;br /&gt;void printMe(int a)&lt;br /&gt;void printMe(float f)&lt;br /&gt;void printMe(double d)&lt;br /&gt;void printMe(char c)&lt;br /&gt;&lt;br /&gt;After declaration of overloading functions, we have to define them in following manner.&lt;br /&gt;&lt;br /&gt;void printMe(int a)&lt;br /&gt;{&lt;br /&gt; cout&lt;&lt;”I am “&lt;&amp;lt;a&lt;&amp;lt;endl;&lt;br /&gt;        &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void printMe(double d)&lt;br /&gt;{&lt;br /&gt; Cout&lt;&lt;”I am “&lt;&amp;lt;d&lt;&amp;lt;endl;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void printMe(char c)&lt;br /&gt;{&lt;br /&gt; Cout&lt;&lt;”I am “&lt;&amp;lt;c&lt;&amp;lt;endl;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now you can understand how easy to work with overloading functions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-8000588632555970823?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/8000588632555970823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=8000588632555970823' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/8000588632555970823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/8000588632555970823'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2008/11/function-overloading.html' title='Function Overloading'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-5355036922081945159</id><published>2008-10-22T11:49:00.000-07:00</published><updated>2008-10-22T12:20:19.345-07:00</updated><title type='text'>Console I/O Streams</title><content type='html'>There are three types of Console I/O Stream-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;cout - Standard Output Stream&lt;br /&gt;cin  - Standard Input Stream&lt;br /&gt;cerr - Standard Error Output Stream&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;cout :&lt;br /&gt;&lt;br /&gt;It is used to display data on console. &lt;br /&gt;Example :&lt;br /&gt;          cout&lt;&lt;"Sachin is a greatest Cricket Player"&lt;br /&gt;          cout&lt;&lt;234;&lt;br /&gt;In general form :&lt;br /&gt;          cout&lt;&lt;expression;&lt;br /&gt;          here expression can  be any valid C++ expression&lt;br /&gt;&lt;br /&gt;cin :&lt;br /&gt;&lt;br /&gt;It is used to capture data from keyword.&lt;br /&gt;Example :&lt;br /&gt;      int age;&lt;br /&gt;      cin&gt;&gt;age;&lt;br /&gt;The general form :&lt;br /&gt;           cin&gt;&gt;variable;&lt;br /&gt;&lt;br /&gt;cerr :&lt;br /&gt;&lt;br /&gt;It is used to display errors on console.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-5355036922081945159?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/5355036922081945159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=5355036922081945159' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/5355036922081945159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/5355036922081945159'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2008/10/console-io-streams.html' title='Console I/O Streams'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-8638279268015085986</id><published>2008-10-22T11:37:00.000-07:00</published><updated>2008-10-22T11:42:21.158-07:00</updated><title type='text'>C++ Keywords</title><content type='html'>Keywords are predefined reserved words (identifiers).They have special meanings. They cannot be used as identifiers in your program. The following keywords are reserved for C++.&lt;br /&gt;&lt;br /&gt;    * asm&lt;br /&gt;    * auto&lt;br /&gt;    * break&lt;br /&gt;    * case&lt;br /&gt;    * catch&lt;br /&gt;    * char&lt;br /&gt;    * class&lt;br /&gt;    * const&lt;br /&gt;    * continue&lt;br /&gt;    * default&lt;br /&gt;    * delete&lt;br /&gt;    * do&lt;br /&gt;    * double&lt;br /&gt;    * else&lt;br /&gt;    * enum&lt;br /&gt;    * explicit&lt;br /&gt;    * extern&lt;br /&gt;    * float&lt;br /&gt;    * for&lt;br /&gt;    * friend&lt;br /&gt;    * goto&lt;br /&gt;    * if&lt;br /&gt;    * inline&lt;br /&gt;    * int&lt;br /&gt;    * long&lt;br /&gt;    * mutable&lt;br /&gt;    * namespace&lt;br /&gt;    * new&lt;br /&gt;    * operator&lt;br /&gt;    * private&lt;br /&gt;    * protected&lt;br /&gt;    * public&lt;br /&gt;    * register&lt;br /&gt;    * return&lt;br /&gt;    * short&lt;br /&gt;    * signed&lt;br /&gt;    * sizeof&lt;br /&gt;    * static&lt;br /&gt;    * struct&lt;br /&gt;    * switch&lt;br /&gt;    * template&lt;br /&gt;    * this&lt;br /&gt;    * throw&lt;br /&gt;    * try&lt;br /&gt;    * typedef&lt;br /&gt;    * union&lt;br /&gt;    * unsigned&lt;br /&gt;    * using&lt;br /&gt;    * virtual&lt;br /&gt;    * void&lt;br /&gt;    * volatile&lt;br /&gt;    * while&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-8638279268015085986?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/8638279268015085986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=8638279268015085986' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/8638279268015085986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/8638279268015085986'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2008/10/c-keywords.html' title='C++ Keywords'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-439698466854617558</id><published>2008-10-17T05:00:00.000-07:00</published><updated>2008-10-17T05:32:15.567-07:00</updated><title type='text'>My First Program</title><content type='html'>Now we will see how to write a program in C++. The idea of this program is to introduce you to the overall structure of a C++ program.&lt;br /&gt;&lt;br /&gt;//My first program&lt;br /&gt;&lt;br /&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;//Print text message on console&lt;br /&gt;&lt;br /&gt;cout&lt;&lt;"Hello Universe.. Give me Red ";&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now after writing program in a text file(Source file) , save text file by name first.c&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Note:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;C++ source files conventionally use one of the suffixes &lt;tt class="COMMAND"&gt;.C&lt;/tt&gt;, &lt;tt class="COMMAND"&gt;.cc&lt;/tt&gt;, &lt;tt class="COMMAND"&gt;.cpp&lt;/tt&gt;, &lt;tt class="COMMAND"&gt;.CPP&lt;/tt&gt;, &lt;tt class="COMMAND"&gt;.c++&lt;/tt&gt;, &lt;tt class="COMMAND"&gt;.cp&lt;/tt&gt;, or &lt;tt class="COMMAND"&gt;.cxx&lt;/tt&gt;;&lt;br /&gt;&lt;br /&gt;if you are using GNU Compiler, you can give following command to compile first.c&lt;br /&gt;&lt;br /&gt; g++   first.c&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To run&lt;br /&gt;&lt;/span&gt;    a.out&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Output will be:&lt;br /&gt;&lt;/span&gt; Hello Universe.. Give me Red&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example 2:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;//Print multiple text messages on console&lt;br /&gt;&lt;br /&gt;cout&lt;&lt;"Hello Universe.. Give me Red "&lt;&amp;lt;endl;&lt;br /&gt;cout&lt;&lt;"Congrats! Sachin ...";&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-439698466854617558?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/439698466854617558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=439698466854617558' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/439698466854617558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/439698466854617558'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2008/10/my-first-program.html' title='My First Program'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-1172377495653331421</id><published>2008-10-16T03:09:00.000-07:00</published><updated>2008-10-16T05:22:19.826-07:00</updated><title type='text'>Constructors &amp; Destructors in C++</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Constructor&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Definition :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Constructor is a special member function with the same name as its class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;class Person&lt;br /&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;  public:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;     Person();      // constructor for class Person&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Use:&lt;/span&gt;&lt;br /&gt;Constructors are used to create, and can initialize, objects of their class type.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Call:&lt;/span&gt;&lt;br /&gt;When an object of a class is created, constructor for that class is called.&lt;br /&gt;&lt;br /&gt;If there is no constructor defined, &lt;span style="font-style: italic;"&gt;DEFAULT constructor&lt;/span&gt; is invoked.&lt;br /&gt;But default constructor doesn't initialize.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Some facts about Constructors :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Constructors are special member functions with the same name as the class.&lt;/li&gt;&lt;li&gt;Constructors can not return any value (nothing even void) .&lt;/li&gt;&lt;li&gt;Constructors are intended to initialize the members of the class when an instance of that class is created.&lt;/li&gt;&lt;li&gt;Constructors are not called directly.&lt;/li&gt;&lt;li&gt;Constructors can not be virtual.&lt;/li&gt;&lt;li&gt;Constructors can not be static.&lt;/li&gt;&lt;li&gt;Constructors can not be const, volatile, or const volatile.&lt;/li&gt;&lt;li&gt;Constructors aren't automatically inherited between base and derived classes.&lt;/li&gt;&lt;li&gt;There can be any number of constructors in a same class. They must have different parameters to distinguish them. (=&gt; Constructors can be overloaded )&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt; Destructors&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Definition :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Destructors in C++ also have the same name, but they are preceded by a '~' operator.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example :&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;class Person {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;public:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;  // Constructor for class Person&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;  Person();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;  // Destructor for class Person&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;  ~Person();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Use :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Destructors are usually used to deallocate memory and do other cleanup for a class object and its class members when the object is destroyed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Call:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The destructors are called when the object of a class goes out of scope or is explicitly deleted.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Some facts about Destructors&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If the constructor/destructor is declared as private, then the class cannot be instantiated. (why? Think about it.)&lt;/li&gt;&lt;li&gt;It is not necessary to declare a constructor or a destructor inside a class. If not declared, the compiler will automatically create a default one for each.&lt;/li&gt;&lt;li&gt;A destructor takes no arguments and has no return type.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Its address cannot be taken.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Destructors cannot be declared const, volatile, const volatile or static.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A destructor can be declared virtual or pure virtual.&lt;/li&gt;&lt;/ul&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:85%;"  &gt; &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-1172377495653331421?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/1172377495653331421/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=1172377495653331421' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/1172377495653331421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/1172377495653331421'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2008/10/constructors-in-c.html' title='Constructors &amp; Destructors in C++'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-8473696755718456989</id><published>2008-09-19T22:40:00.000-07:00</published><updated>2008-09-20T00:37:49.269-07:00</updated><title type='text'>Inheritance in C++</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153); font-family: arial;font-size:180%;" &gt;Inheritance &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:130%;"&gt;It is a mechanism to reuse and extend existing classes.&lt;br /&gt;&lt;br /&gt;Creating and deriving a class from existing class is also known as inheritance in C++.&lt;br /&gt;&lt;br /&gt;New Created class is called &lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Derived Class&lt;/span&gt;&lt;span style="font-size:130%;"&gt; and extended class (old class) is called &lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Base class&lt;/span&gt;&lt;span style="font-size:130%;"&gt;.&lt;br /&gt;&lt;br /&gt;Derived class can have all the features of base class and we can add new features to derived class.&lt;br /&gt;&lt;br /&gt;Adding new features in base class to make derived class is called extension of base class.&lt;br /&gt;&lt;br /&gt;In general we can formulate it-&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153); font-weight: bold;font-size:130%;" &gt;Base Class + New features = Derived Class&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;br /&gt;Example :&lt;br /&gt;  We can create a base class named &lt;span style="font-weight: bold;"&gt;fruit &lt;/span&gt;and define derived classes as , &lt;span style="font-weight: bold;"&gt;mango, apple&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;banana&lt;/span&gt; Each of these derived classes has all the features of the base class (fruit) with extra attributes or features specific to these  derived classes. Mango would have its own defined features, apple would have its own defined features,  banana would have its own defined features, etc.&lt;br /&gt;&lt;br /&gt;C++ inheritance is similar to a parent-child relationship. According to inheritance concept, When a class is inherited all the functions and data member are inherited. In C++, every thing from the base class can not be inherited. Yes! we are talking about some exceptional cases. Just have a look-&lt;br /&gt;&lt;br /&gt;We can't inherit-&gt;&lt;br /&gt;&lt;/span&gt; &lt;ul&gt;&lt;li&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;The constructor and destructor of a base class&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;The assignment operator&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;The friend functions and friend classes of the base class&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;    &lt;span style="font-size:130%;"&gt;&lt;span style="font-style: italic;"&gt;(Don't worry .. Very soon we will learn about friends..   &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Yes friends are also there in C++. They will become your fast friend in certain cases.)&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-8473696755718456989?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/8473696755718456989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=8473696755718456989' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/8473696755718456989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/8473696755718456989'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2008/09/inheritance-in-c.html' title='Inheritance in C++'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-6706766900142789250</id><published>2007-05-12T00:27:00.000-07:00</published><updated>2008-09-20T00:43:54.593-07:00</updated><title type='text'>What is Object?</title><content type='html'>&lt;hr style="height: 4px;font-size:100%;color:orange;"   noshade="noshade"&gt; &lt;span style="font-size:130%;"&gt;&lt;br /&gt;Object is like a variable &lt;/span&gt;&lt;span style="font-size:130%;"&gt;as we create with built-in datatypes. Object is an instance of class.&lt;br /&gt;Object has state,behavior and identity.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;state&lt;/b&gt; - value of data member at any point of time&lt;br /&gt;&lt;b&gt;behaviour&lt;/b&gt; - how object performing a task, it comes from definition of member functions.&lt;br /&gt;&lt;b&gt;identity&lt;/b&gt; - name of object.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to create Object?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Syntax:&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;   &lt;b&gt;class-name object-name;&lt;/b&gt;&lt;br /&gt;or&lt;br /&gt;   &lt;b&gt;class-name object-name1,object-name2,....;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Suppose we have to create object(s) of class Circle :&lt;br /&gt;&lt;br /&gt;Circle c; //One object created&lt;br /&gt;or&lt;br /&gt;Circle c1,c2; //Two objects created&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to call a member function?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;Syntax : &lt;/i&gt;&lt;/b&gt;&lt;br /&gt;   &lt;b&gt;object-name.member-function-name();&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;for example we want to set radius of object c , we have to call a member function SetRadius(int) :&lt;br /&gt;-&gt;&lt;br /&gt;c.SetRadius(12);&lt;br /&gt;in same way&lt;br /&gt;int area = c.GetArea();&lt;br /&gt;&lt;br /&gt;and so on....&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Class Members :&lt;/b&gt;&lt;br /&gt;    Data Member&lt;br /&gt;    Member Function&lt;br /&gt;Members must be declared/defined within class definition.&lt;br /&gt;A member can not be declared twice in the class definition.&lt;br /&gt;&lt;br /&gt;Now let's assemble all the pieces together to make it meaningful..&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;font-size:130%;color:green;"&gt;&lt;br /&gt;//class definition&lt;br /&gt;class A&lt;br /&gt;{&lt;br /&gt;//data member&lt;br /&gt;int i;&lt;br /&gt;int j;&lt;br /&gt;&lt;br /&gt;//member function&lt;br /&gt;int getI()     //definition of member function&lt;br /&gt;{&lt;br /&gt;  return i;&lt;br /&gt;}&lt;br /&gt;void setI(int a)     //definition of member function&lt;br /&gt;{&lt;br /&gt;  i = a;&lt;br /&gt;}&lt;br /&gt;};&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  A aObj; //Creation of object&lt;br /&gt;  aObj.setI(20); //calling member function&lt;br /&gt;  cout&lt;&amp;amp;ltaObj.getI(); //calling member function&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;marquee bg style="color:orange;"&gt;&lt;span style="font-size:130%;"&gt; Please visit us again .Updation is ongoing process here...Thanks&lt;/span&gt;&lt;/marquee&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-6706766900142789250?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/6706766900142789250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/6706766900142789250'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/05/what-is-object.html' title='What is Object?'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-2063287208055151438</id><published>2007-05-11T22:41:00.000-07:00</published><updated>2007-05-12T02:10:59.300-07:00</updated><title type='text'>Class &amp; Objects</title><content type='html'>&lt;b&gt;&lt;font face="verdana" color="blue" size="3"&gt;&lt;br /&gt;Class:&lt;/font&gt;&lt;/b&gt; It is a basic block of Object Oriented Software.&lt;br /&gt;Class is like a data type as struct in C. A datatype contains data and operations applicable to that data. We can take example of int data type, it contains data as well as operations like a+b , a-b , a*b etc.&lt;br /&gt;&lt;br /&gt;In other words, class is a blueprint for objects. class decides what object can have and what task it can perform.&lt;br /&gt;&lt;br /&gt;Now we will see, how class concept can be implemented through C++ -&lt;br /&gt;&lt;br /&gt;&lt;I&gt;General Form of Class&lt;/I&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;class &lt;class-name&gt;&lt;br /&gt;{&lt;br /&gt;  data member;&lt;br /&gt;&lt;br /&gt;  member functions;&lt;br /&gt;&lt;br /&gt;};&lt;/b&gt;  // ; is must here&lt;br /&gt;&lt;br /&gt;Example :&lt;br /&gt;&lt;font face="arial" color="green"&gt;&lt;br /&gt;class Circle&lt;br /&gt;{&lt;br /&gt;int radius;&lt;br /&gt;&lt;br /&gt;int GetRadius();&lt;br /&gt;void SetRadius(int);&lt;br /&gt;int CalculateArea(int);&lt;br /&gt;};&lt;br /&gt;&lt;/font&gt;:&lt;br /&gt;&lt;br /&gt;In above example , we have seen how a class look like .&lt;br /&gt;As we know by default, all members of class have private access-specifier. So in above class Circle, all the members will be private,means they can not be accessed from outside the class.Before discussing further, first we have a idea regarding Access Specifier :-&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Access-Specifier&lt;/B&gt; : also known as &lt;b&gt;visibility labels&lt;/b&gt;.&lt;br /&gt;There are three types of Access specifiers&lt;br /&gt;&lt;br /&gt;&lt;b&gt;private&lt;/b&gt; : private members can be accessed only within the class itself.&lt;br /&gt;&lt;b&gt;public&lt;/b&gt; : public members can be accessed from outside the class also.In this case, member is fully exposed to outside-world.&lt;br /&gt;&lt;b&gt;protected&lt;/b&gt; : can be access from derived class only.(&lt;i&gt;We will discuss this in detail during inheritance topic&lt;/i&gt;)&lt;br /&gt;&lt;br /&gt;Now again we take above example. none of the member can be accessed from outside of the class, now to make some member accessible from outside we make one little but very important modification -&lt;br /&gt;&lt;br /&gt;&lt;font face="arial" color="green"&gt;&lt;br /&gt;class Circle&lt;br /&gt;{&lt;br /&gt;int radius;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;public:&lt;/b&gt;&lt;br /&gt;int GetRadius();&lt;br /&gt;void SetRadius(int);&lt;br /&gt;int CalculateArea(int);&lt;br /&gt;};&lt;br /&gt;&lt;/font&gt;:&lt;br /&gt;&lt;br /&gt;Now, to use this definition of class , Let's understand &lt;a href="http://learncpp.blogspot.com/2007/05/what-is-object.html"&gt;What is Object?&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-2063287208055151438?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/2063287208055151438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/2063287208055151438'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/05/class-objects.html' title='Class &amp; Objects'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-452233046343707358</id><published>2007-05-05T04:37:00.000-07:00</published><updated>2007-05-12T02:29:45.015-07:00</updated><title type='text'>C++ Structure vs C++ Class</title><content type='html'>C++ programming language provides structure and class to create problem-oriented datatypes.Instance of these datatypes are known as objects.&lt;br /&gt;&lt;br /&gt;C++ Structure and C++ class are exactly same except default access specifier of their members i.e. in C++ Structure all members are public by default while in Class all are private.&lt;br /&gt;&lt;br /&gt;For example in following  code , the class C is equivalent to structure S&lt;br /&gt;&lt;br /&gt;class C&lt;br /&gt;{&lt;br /&gt;//default access specifier is private&lt;br /&gt;int num;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;void setNum(int n)&lt;br /&gt;{&lt;br /&gt;Num = n;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;struct S&lt;br /&gt;{&lt;br /&gt;//default access specifier is public&lt;br /&gt;void setNum(int n)&lt;br /&gt;{&lt;br /&gt;Num = n;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt;int num;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Hence we can see here that the difference in both is only access specifier, but as security is concern, this is a big drawback of structure.Because by default all the members are exposed to outside world. That is the one main reason, why programmers are hesitant to use structure.In turn, class encourages encapsulation/data-hiding by default.So my recommendation is &lt;i&gt;use class, forget structure&lt;/i&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-452233046343707358?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/452233046343707358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/452233046343707358'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/05/c-structure-vs-c-class.html' title='C++ Structure vs C++ Class'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-2278856248980012490</id><published>2007-05-03T05:34:00.000-07:00</published><updated>2008-10-16T05:42:34.369-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C vs C++'/><title type='text'>C Structure vs  C++ Structure</title><content type='html'>&lt;span style="font-weight: bold;"&gt;C Structure contains only data items while C++ structure contains data as well as function.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In C to create structure variable you have to use 'struct' keyword for example&lt;br /&gt;struct Person p;&lt;br /&gt;&lt;br /&gt;But in C++ 0nly Structure name is used just like built-in datatype. for example&lt;br /&gt;Person p;&lt;br /&gt;&lt;br /&gt;Example :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;C Structure :&lt;/span&gt;&lt;br /&gt;struct Person&lt;br /&gt;{&lt;br /&gt;int pid;&lt;br /&gt;char name[25];&lt;br /&gt;....&lt;br /&gt;}&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Declaration of a variable&lt;/span&gt;&lt;br /&gt;struct Person p;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;C++ Structure :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;struct Person&lt;br /&gt;{&lt;br /&gt;int pid;&lt;br /&gt;char name[25];&lt;br /&gt;....&lt;br /&gt;void enterDetails()&lt;br /&gt;{&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;..&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Declaration of a variable:&lt;/span&gt;&lt;br /&gt;Person p;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-2278856248980012490?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/2278856248980012490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/2278856248980012490'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/05/c-structure-vs-c-structure.html' title='C Structure vs  C++ Structure'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-1392603408560967101</id><published>2007-05-02T00:49:00.000-07:00</published><updated>2008-10-16T05:47:34.207-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Basics Of C++'/><title type='text'>Basic Features</title><content type='html'>&lt;b&gt;Stream :&lt;/b&gt; It is a flow of data to and fro.&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;Standard Input Stream&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;u&gt;&lt;/u&gt;&lt;/i&gt;&lt;u&gt;&lt;/u&gt;&lt;br /&gt;Used to read data form Standard Input device i.e. keyboard ,it can take input from a file stored at hard disk and from other input devices also.&lt;br /&gt;'cin' represents the Standard Input Stream.&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;Standard Output Stream&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;u&gt;&lt;/u&gt;&lt;/i&gt;&lt;u&gt;&lt;/u&gt;&lt;br /&gt;Used to send output to Standard Output Device i.e. Monitor, it can send output to file on hard-disk,printer etc.&lt;br /&gt;'cout' represents the Standard Output Stream.&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;Standard Error Stream&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;u&gt;&lt;/u&gt;&lt;/i&gt;&lt;u&gt;&lt;/u&gt;&lt;br /&gt;Another output stream used by programs to output error messages.&lt;br /&gt;'cerr' represents the Standard Error Stream.&lt;br /&gt;&lt;br /&gt;The iostream is an object-oriented library that contains input and output streams.&lt;br /&gt;&lt;br /&gt;C++ provide two ways to work with streams :&lt;br /&gt; low-level&lt;br /&gt; high-level&lt;br /&gt;&lt;i&gt;Very soon we will get detailed description of this topic...&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;C++ Comments &lt;/b&gt;&lt;br /&gt;Single line comment&lt;br /&gt; // single line statement here&lt;br /&gt;Multiline Comment&lt;br /&gt;/*&lt;br /&gt; Some lines here&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt; References &lt;/u&gt;&lt;/b&gt;&lt;u&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;C++ references are to create alternative name or alias name for the already defined variable.&lt;br /&gt;  for example :&lt;br /&gt;     int i = 18;&lt;br /&gt;     int &amp;amp;ref = i;&lt;br /&gt;           here ref is reference to integer variable i. it can be used in place of i.&lt;br /&gt;-&gt;&amp;amp; is not address operator here, it is reference operator.&lt;-  &lt;i&gt;REMEMBER : &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;  * No memory is allocated for reference variables as they are alias name for simple variables.&lt;br /&gt;  * Reference variables should be initialized.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Main Use :&lt;/i&gt;&lt;br /&gt;  * as a formal argument to a function.&lt;br /&gt;Example :&lt;br /&gt;--------------------------------------&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;int Square(int &amp;amp;Val);&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;   int Number=10;&lt;br /&gt;   Square(Number);&lt;br /&gt;   cout&lt;&lt;"Number is "&lt;&lt;&gt;Pointer Reference:&lt;/i&gt;&lt;br /&gt;It is Alias name to the pointer.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;int ival = 100;&lt;br /&gt;int *ptr = &amp;ival;&lt;br /&gt;int * &amp;amp;refptr = ptr;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Scope Resolution Operator :&lt;/b&gt;&lt;br /&gt;In C a local variable has precedence over global variable with the same name.&lt;br /&gt;In C++, global variable can be accessed through Scope Resolution Operator :: ,with local variable.&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;int i = 4;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;int i = 9;&lt;br /&gt;cout&lt;&lt; ::i&lt;&lt; endl;   //Prints global variable i 4&lt;br /&gt;cout&lt;&lt; i;           //Prints local variable i 9&lt;br /&gt;}&lt;br /&gt;}&lt;/iostream&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-1392603408560967101?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/1392603408560967101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/1392603408560967101'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/05/streams.html' title='Basic Features'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-3061175127174963024</id><published>2007-04-30T07:05:00.000-07:00</published><updated>2008-10-16T05:44:13.488-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Basics Of C++'/><title type='text'>Features Of C++</title><content type='html'>Following are the various features of C++  :&lt;br /&gt;   Streams for I/O&lt;br /&gt;   Comments&lt;br /&gt;   Function Prototypes&lt;br /&gt;   Default Function Arguments&lt;br /&gt;   Variables&lt;br /&gt;   Scope Resolution Operator&lt;br /&gt;   The Const qualifier&lt;br /&gt;   Enumeration&lt;br /&gt;   Inline Function&lt;br /&gt;   References&lt;br /&gt;   Overloaded functions&lt;br /&gt;   Class&lt;br /&gt;   Object&lt;br /&gt;   Access Specifiers&lt;br /&gt;      &lt;br /&gt;              and many more.....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-3061175127174963024?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learncpp.blogspot.com/feeds/3061175127174963024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3202817326633385344&amp;postID=3061175127174963024' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/3061175127174963024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/3061175127174963024'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/04/features-of-c.html' title='Features Of C++'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-8746074418066817895</id><published>2007-04-30T06:17:00.000-07:00</published><updated>2008-10-16T05:42:06.010-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C vs C++'/><title type='text'>C vs C++</title><content type='html'>&lt;b&gt;What C++ is having C not : &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;References&lt;br /&gt;boolean type&lt;br /&gt;Inline substitution&lt;br /&gt;Default function arrays&lt;br /&gt;Free Store Management Operators i.e. new and delete&lt;br /&gt;Function Overloading&lt;br /&gt;Operator Overloading&lt;br /&gt;RTTI (Run Time Type Information)&lt;br /&gt;Namespaces&lt;br /&gt;Eclipses&lt;br /&gt;default arguments&lt;br /&gt;I/O i.e. cin &amp;amp; cout&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-8746074418066817895?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/8746074418066817895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/8746074418066817895'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/04/c-vs-c.html' title='C vs C++'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-6955955324941577453</id><published>2007-04-30T05:13:00.000-07:00</published><updated>2007-05-12T02:30:16.602-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOPS'/><title type='text'>What is Object Oriented Programming(OOP) ?</title><content type='html'>As its name indicates , it is a technique which is organised around object.Hence object is CYNOSURE here.Here main focus point is data. Functions are secondary. In very simple terms, functions are data oriented , means in what way data is going to be used in program that is described in function. so data and functions are tied together to make "Object".&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Features of OOPs:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;  Abstraction&lt;br /&gt;  Encapsulation&lt;br /&gt;  Inheritance&lt;br /&gt;  Polymorphism&lt;br /&gt;&lt;br /&gt;&lt;B&gt; Abstraction: &lt;/B&gt;&lt;br /&gt;           Abstraction is the process of hiding the details and exposing only the essential features of a object according to the context or problem domain.&lt;br /&gt;&lt;br /&gt;IEEE Definition :&lt;br /&gt;        "A view of a problem that extracts the essential information&lt;br /&gt; relevant to a particular purpose and ignores the remainder of&lt;br /&gt; the information."&lt;br /&gt;&lt;br /&gt;  -- [IEEE, 1983]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt; Encapsulation: &lt;/b&gt;&lt;br /&gt;           Encapsulation is the ability to bundle related data and functionality within a single, autonomous entity called a class. &lt;br /&gt;&lt;br /&gt;&lt;b&gt; Inheritance: &lt;/b&gt;&lt;br /&gt;           Inheritance is a mechanism to create new classes through already existing classes.&lt;br /&gt;&lt;br /&gt;&lt;b&gt; Polymorphism: &lt;/b&gt;&lt;br /&gt;           Poly means "many" morphism means "forms" hence verbal meaning is many forms. It is a way in which one name can provide different functionalities.  &lt;br /&gt;        -&gt; the ability to provide the same interface to objects with differing implementations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-6955955324941577453?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/6955955324941577453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/6955955324941577453'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/04/what-is-object-oriented-programmingoop.html' title='What is Object Oriented Programming(OOP) ?'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-3202817326633385344.post-1731384229319961430</id><published>2007-04-30T04:48:00.000-07:00</published><updated>2008-10-17T03:42:26.109-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Basics Of C++'/><title type='text'>What is C++ ?</title><content type='html'>&lt;hr /&gt;&lt;span style="font-style: italic;"&gt;Welcome to C++ Learning Sessions..&lt;br /&gt;&lt;br /&gt;C++ is very entertaining and one of the most used programming language. I hope you will enjoy learning this beautiful programming language.&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; ALL THE BEST.&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-size:130%;" &gt;C++ Fact File&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;C++ is a Object Oriented Programming Language, developed by Bjarne Stroustrup in 1983 at Bell lab.&lt;br /&gt;&lt;br /&gt;It is a powerful general purpose language which contains almost all the features of C including low level features like memory management,pointers etc.&lt;br /&gt;&lt;br /&gt;One major advantage over C is object oriented features of C++. From small-scale to large-scale application can be created in C++.&lt;br /&gt;&lt;br /&gt;It also supports other programming approaches like Procedural,Object-based programming, Generic programming, and Functional programming.&lt;br /&gt;&lt;br /&gt;Originally it was named as "C with Classes".&lt;br /&gt;&lt;br /&gt;C++ is also considered as Superset of C.&lt;br /&gt;&lt;br /&gt;C++ is having a special concept called "operator overloading". This concept is not present in the earlier OOP languages and it makes the creation of libraries much cleaner and easy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3202817326633385344-1731384229319961430?l=learncpp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/1731384229319961430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3202817326633385344/posts/default/1731384229319961430'/><link rel='alternate' type='text/html' href='http://learncpp.blogspot.com/2007/04/what-is-c.html' title='What is C++ ?'/><author><name>SatyAnveshak</name><uri>http://www.blogger.com/profile/16062233303579529315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
