





<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Durofy &#187; object-oriented programming</title>
	<atom:link href="http://www.durofy.com/tag/object-oriented-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.durofy.com</link>
	<description>Engineering &#38; Technology Blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 04:41:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Understanding Inheritance in OOP</title>
		<link>http://www.durofy.com/programming/understanding-inheritance-in-oop/</link>
		<comments>http://www.durofy.com/programming/understanding-inheritance-in-oop/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 06:45:56 +0000</pubDate>
		<dc:creator>Rishabh Dev</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c sample program]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[c++ inheritance]]></category>
		<category><![CDATA[c++ programming]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[derived classes oop]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[inheritance c++]]></category>
		<category><![CDATA[inheritance concept]]></category>
		<category><![CDATA[object-oriented programming]]></category>
		<category><![CDATA[oop inheritance]]></category>

		<guid isPermaLink="false">http://zarrata.com/durofy/?p=168</guid>
		<description><![CDATA[The example below explains inheritance, an important property of OOP languages. We have three classes: living, animal &#38; dog. The dog inherits all the characteristics of living &#38; animal base classes however, the plant does not(being an instance of just the living class). #include&#60;iostream&#62; using namespace std; class living { int energy; public: void getenergy() [...]]]></description>
			<content:encoded><![CDATA[<p>The example below explains inheritance, an important property of OOP languages.</p>
<p>We have three classes: living, animal &amp; dog. The dog inherits all the characteristics of living &amp; animal base classes however, the plant does not(being an instance of just the living class).</p>
<pre>#include<span style="color: blue; font-size: xx-small;">&lt;</span>iostream<span style="color: blue; font-size: xx-small;">&gt;</span>
using namespace std<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: red;"><strong>class</strong></span> living
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
      <span style="color: red;"><strong>int</strong></span> energy<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
      <span style="color: red;"><strong>public</strong></span><span style="color: blue; font-size: xx-small;">:</span>
                <span style="color: red;"><strong>void</strong></span> getenergy<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
                <span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
                     cout<span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: purple;">"Gets energy"</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span>endl<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
                     <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: red;"><strong>class</strong></span> animal<span style="color: blue; font-size: xx-small;">:</span><span style="color: red;"><strong>public</strong></span> living
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
      <span style="color: red;"><strong>int</strong></span> feet<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
      <span style="color: red;"><strong>public</strong></span><span style="color: blue; font-size: xx-small;">:</span>
                <span style="color: red;"><strong>void</strong></span> move<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
                <span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
                     cout<span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: purple;">"It moves"</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span>endl<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
                     <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: red;"><strong>class</strong></span> dog<span style="color: blue; font-size: xx-small;">:</span><span style="color: red;"><strong>public</strong></span> animal
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>

      <span style="color: red;"><strong>int</strong></span> tail<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
      <span style="color: red;"><strong>public</strong></span><span style="color: blue; font-size: xx-small;">:</span>
                <span style="color: red;"><strong>void</strong></span> bark<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
                <span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
                     cout<span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: purple;">"It barks"</span><span style="color: blue; font-size: xx-small;">&lt;</span><span style="color: blue; font-size: xx-small;">&lt;</span>endl<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
                     <span style="color: blue; font-size: xx-small;"><strong>}</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: red;"><strong>int</strong></span> <span style="color: red;"><strong>main</strong></span><span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>{</strong></span>
    living plant<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    plant<span style="color: blue; font-size: xx-small;"><strong>.</strong></span>getenergy<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

    dog phoenix<span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    phoenix<span style="color: blue; font-size: xx-small;"><strong>.</strong></span>getenergy<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    phoenix<span style="color: blue; font-size: xx-small;"><strong>.</strong></span>move<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    phoenix<span style="color: blue; font-size: xx-small;"><strong>.</strong></span>bark<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>

    system<span style="color: blue; font-size: xx-small;"><strong>(</strong></span><span style="color: purple;">"pause"</span><span style="color: blue; font-size: xx-small;"><strong>)</strong></span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
    <span style="color: red;"><strong>return</strong></span> <span style="color: #a52a2a;">0</span><span style="color: blue; font-size: xx-small;"><strong>;</strong></span>
<span style="color: blue; font-size: xx-small;"><strong>}</strong></span></pre>
<p>The dog inherits the properties of animal which inherits the properties of living. Hence, this inheritance is an example of "Multi-level" inheritance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.durofy.com/programming/understanding-inheritance-in-oop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 Major Differences Between C And C++</title>
		<link>http://www.durofy.com/programming/10-major-differences-between-c-and-c/</link>
		<comments>http://www.durofy.com/programming/10-major-differences-between-c-and-c/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 17:23:23 +0000</pubDate>
		<dc:creator>Rishabh Dev</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[10 differences c c++]]></category>
		<category><![CDATA[c c++ difference]]></category>
		<category><![CDATA[c vs c++]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[c++ programming]]></category>
		<category><![CDATA[differences between c and c++]]></category>
		<category><![CDATA[main difference c c++]]></category>
		<category><![CDATA[major differences c and c++]]></category>
		<category><![CDATA[object-oriented programming]]></category>
		<category><![CDATA[procedural programming]]></category>

		<guid isPermaLink="false">http://zarrata.com/durofy/?p=81</guid>
		<description><![CDATA[&#160; C++, as the name suggests is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. Here are the 10 major differences between C++ &#38; C... 1. C follows the procedural programming paradigm while C++ is a multi-paradigm language(procedural as well as [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>C++, as the name suggests is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. Here are the 10 major differences between C++ &amp; C...</p>
<p>1. C follows the procedural programming paradigm while C++ is a <a href="http://zarrata.com/durofy/programming/c-as-a-multi-paradigm-programming-language/">multi-paradigm</a> language(procedural as well as object oriented)</p>
<blockquote><p>In case of C, importance is given to the steps or procedure of the program while C++ focuses on the data rather than the process.<br />
Also, it is easier to implement/edit the code in case of C++ for the same reason.</p></blockquote>
<p>2. In case of C, the data is not secured while the data is secured(hidden) in C++</p>
<blockquote><p>This difference is due to specific <a href="http://zarrata.com/durofy/programming/the-basics-of-object-oriented-programming/">OOP features</a> like Data Hiding which are not present in C.</p></blockquote>
<p>3. C is a low-level language while C++ is a middle-level language (Relatively, Please see the discussion at the end of the post)</p>
<blockquote><p>C is regarded as a low-level language(difficult interpretation &amp; less user friendly) while C++ has features of both low-level(concentration on whats going on in the machine hardware) &amp; high-level languages(concentration on the program itself) &amp; hence is regarded as a middle-level language.</p></blockquote>
<p>4. C uses the top-down approach while C++ uses the bottom-up approach</p>
<blockquote><p>In case of C, the program is formulated step by step, each step is processed into detail while in C++, the base elements are first formulated which then are linked together to give rise to larger systems.</p></blockquote>
<p>5. C is function-driven while C++ is object-driven</p>
<blockquote><p>Functions are the building blocks of a C program while objects are building blocks of a C++ program.</p></blockquote>
<p>6. C++ supports function overloading while C does not</p>
<blockquote><p>Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of <a href="http://zarrata.com/durofy/programming/the-basics-of-object-oriented-programming/">Polymorphism</a>(an OOP feature)</p></blockquote>
<p>7. We can use functions inside structures in C++ but not in C.</p>
<blockquote><p>In case of C++, functions can be used inside a structure while structures cannot contain functions in C.</p></blockquote>
<p>8. The NAMESPACE feature in C++ is absent in case of C</p>
<blockquote><p>C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace &amp; hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier)</p></blockquote>
<p>9. The standard input &amp; output functions differ in the two languages</p>
<blockquote><p>C uses scanf &amp; printf while C++ uses cin&gt;&gt; &amp; cout&lt;&lt; as their respective input &amp; output functions</p></blockquote>
<p>10. C++ allows the use of reference variables while C does not</p>
<blockquote><p>Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming.</p></blockquote>
<hr />
<p>Don't forget to check out :</p>
<ul>
<li><strong><a href="http://zarrata.com/durofy/programming/10-major-differences-between-c-and-java/">10 Major Differences Between C And JAVA</a></strong></li>
<li><strong><a href="http://zarrata.com/durofy/tutorials/c-programming-tutorials/">C programming Tutorials</a></strong></li>
<li><strong><a href="http://zarrata.com/durofy/tutorials/cplusplus-programming-tutorials/">C++ Programming Tutorials</a></strong></li>
</ul>
<hr />
<p><strong>MORE -</strong></p>
<p>11. C++ supports Exception Handling while C does not.</p>
<blockquote><p>C does not support it "formally" but it can always be implemented by other methods. Though you don't have the framework to throw &amp; catch exceptions as in C++.</p></blockquote>
<p>(will add more..)</p>
<hr />
<p><strong>UPDATES (ref to comments)-</strong></p>
<p><strong>Praveen</strong> - some of them r telling ‘C’ is a middle level language…..tell me the correct type of level language….?</p>
<p><strong>Answer-@praveen</strong> – I agree there are always mixed opinions about this one. Some even like to call it a high-level language. But there’s really no determining factor behind the level of a programming language. Essentially, we’re making all the changes at the machine level, right? Now, as we increase the abstraction and move away from the machine-level, the level of the language increases. So, the level is nothing but the level of abstraction. So, most of the languages we use in applications today will have aspects of both machine-level and user-level. The two levels are machine-level &amp; user(real world)-level while high &amp; low levels are relative terms. Although, C is on a lower level of abstraction “relatively”- when compared to C++. Hence, referred to here as low-level.</p>
<p><strong>Mitchell -</strong><br />
cin and cout are part of the std namespace, and they’re not functions. They’re almost like “pipes” in a sense. What you’re doing is essentially bit shifting (&lt;&gt; are bit shift operators) data into and out of them. As well, C++ still supports use of printf and scanf, so your std.cin and std.cout are by no means exclusive in their duties.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.durofy.com/programming/10-major-differences-between-c-and-c/feed/</wfw:commentRss>
		<slash:comments>176</slash:comments>
		</item>
		<item>
		<title>The Basics Of Object Oriented Programming</title>
		<link>http://www.durofy.com/programming/the-basics-of-object-oriented-programming/</link>
		<comments>http://www.durofy.com/programming/the-basics-of-object-oriented-programming/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 15:56:11 +0000</pubDate>
		<dc:creator>Rishabh Dev</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[abstraction data]]></category>
		<category><![CDATA[basics oop]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[encapsulation]]></category>
		<category><![CDATA[fundamental of oop]]></category>
		<category><![CDATA[information hiding]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[object oriented paradigm]]></category>
		<category><![CDATA[object-oriented programming]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[polymorphism]]></category>

		<guid isPermaLink="false">http://zarrata.com/durofy/?p=49</guid>
		<description><![CDATA[As I pointed out in my previous post, we use classes in Object Oriented Programming(OOP) which are a blueprint of objects that share common properties. This use of classes &#038; more precisely, of objects makes the process of programming easy &#038; efficient. That was exactly the reason why the Object Oriented Programming Paradigm was introduced. [...]]]></description>
			<content:encoded><![CDATA[<p>As I pointed out in my <a href="http://zarrata.com/durofy/programming/c-as-a-multi-paradigm-programming-language/">previous post</a>, we use classes in Object Oriented Programming(OOP) which are a blueprint of objects that share common properties. This use of classes &#038; more precisely, of objects makes the process of programming easy &#038; efficient.</p>
<p>That was exactly the reason why the Object Oriented Programming Paradigm was introduced. Now, there are certain fundamental features that you would find in every object oriented programming language.</p>
<p><img src="http://i28.tinypic.com/zvwgif.jpg"></p>
<p>Lets now take a look at each of them individually,<br />
Lets take up CLASSES first. They consists of entities called objects-or they are blueprints of objects.</p>
<p>For example, a car would be a class &#038; a van would be an object that belongs to the class called cars. Now, once we know the behavior of this object, we can use it anywhere we need in the program without having to define the behavior/properties again &#038; again, which is the basic aim of OOP.</p>
<p>The objects here act as building blocks of the program. Though the objects can differ in terms of specific attributes(like a van could be red or blue), the classes would only depict the common behavior of all objects(like each car would have 4 wheels, turn left, right &#038; so on...)</p>
<p>Now, the basic features of OOP...</p>
<p>A) <strong><font color="green">Polymorphism</font></strong> - It simply implies "something having various forms".<br />
In the OOP world, this is evident with variables &#038; functions.(and hence, with objects as well)</p>
<p>For instance, A variable called <strong>MEMBERID</strong> could take a name or a number &#038; the program would recognize &#038; accept both.</p>
<p>Another example is the "<strong>+</strong>" sign which can denote the mathematical operation, or strings or lists.</p>
<p>B) <strong><font color="green">Inheritance</font></strong> - It is simply forming new classes(derived classes) from previously existing ones(base classes). In the process, the derived classes inherit certain properties of the base classes.</p>
<p>The concept is similar to how children inherit certain features from their parents, hence, the base classes are also sometimes refereed to as ancestor classes.</p>
<p>In terms of relationships, we call the relation between the base &#038; derived class the <em>as-is</em> relationship. Consider the base class "car" &#038; the derived class "bmw". Then we can say "bmw" <em>is-a</em> "car" which is generalized to "derived class" <em>is-a</em> "base class".</p>
<p>Encapsulation, Data Abstraction &#038; Information hiding are very similar concepts &#038; people often confuse them to be the same.</p>
<p>In one single statement, <strong><font color="blue">Abstraction</font></strong> is a technique that lets us know what information should be visible, and what information should be hidden. <strong><font color="blue">Encapsulation</font></strong> is the technique to display the information in a way as to hide what should be hidden, and show what's needed.<br />
Then, <strong><font color="blue">Information Hiding</font></strong> is the process of hiding all the inessential details of an object.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.durofy.com/programming/the-basics-of-object-oriented-programming/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>[C++ Tutorial 2] Multi-Paradigm Programming</title>
		<link>http://www.durofy.com/programming/c-as-a-multi-paradigm-programming-language/</link>
		<comments>http://www.durofy.com/programming/c-as-a-multi-paradigm-programming-language/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 16:13:51 +0000</pubDate>
		<dc:creator>Rishabh Dev</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[c++ programming]]></category>
		<category><![CDATA[multi-paradigm]]></category>
		<category><![CDATA[multi-paradigm languages]]></category>
		<category><![CDATA[object-oriented programming]]></category>
		<category><![CDATA[programming language]]></category>
		<category><![CDATA[programming paradigm]]></category>

		<guid isPermaLink="false">http://zarrata.com/durofy/?p=46</guid>
		<description><![CDATA[Whenever the programmers feel the need to change the basic layout of setting up a program, a new paradigm is introduced. Computer languages can then be classified based on the respective paradigm. A programming paradigm is nothing but a style of programming. In one paradigm we may concentrate on the logic, in another, we may [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever the programmers feel the need to change the basic layout of setting up a program, a new paradigm is introduced. Computer languages can then be classified based on the respective paradigm.</p>
<p>A programming paradigm is nothing but a style of programming. In one paradigm we may concentrate on the logic, in another, we may stress on the structure or procedure of our program.</p>
<p>C++ is a programming language that uses three such paradigms &amp; hence, is said to be a Multi-Paradigm programming language.</p>
<p>A) <strong>Generic</strong> - We generalize concepts as <em>templates</em> &amp; reuse them in the source code.</p>
<p>B) <strong>Imperative</strong> - We work with a sequence of commands so as to change the <em>state</em> of the program.</p>
<p>(Procedural Programming is the most common way this can be done. Structural Programming is a subset of Procedural programming)</p>
<p>C) <strong>Object-Oriented</strong> - We use classes which are blueprints of objects that share common behavior &amp; properties.</p>
<p>(The focus here is on the data &amp; instructions rather than the process).</p>
<p>[Go to <a href="http://zarrata.com/durofy/computers/programming/c-tutorial-3-basic-program-structure/">Tutorial 3</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.durofy.com/programming/c-as-a-multi-paradigm-programming-language/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

