{"id":9944,"date":"2014-10-04T05:10:17","date_gmt":"2014-10-03T19:10:17","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=9944"},"modified":"2016-03-28T12:23:29","modified_gmt":"2016-03-28T02:23:29","slug":"c-xcode-oop-friend-overload-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/c-xcode-oop-friend-overload-tutorial\/","title":{"rendered":"C++ Xcode OOP Friend Overload Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FriendOverload\/colour_cpp.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"C++ Xcode OOP FriendOverload Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FriendOverload\/colour_cpp.jpg\" title=\"C++ Xcode OOP FriendOverload Tutorial\"  \/><\/a><p class=\"wp-caption-text\">C++ Xcode OOP Friend Overload Tutorial<\/p><\/div>\n<p>Our C++ Xcode OOP Friend (Operator) Overloading Tutorial presented here builds off the previous <a target=_blank href='#cxomit' title='C++ Xcode OOP Multiple Inheritance Tutorial'>C++ Xcode OOP Multiple Inheritance Tutorial<\/a> as shown below.<\/p>\n<p>You can use friend functions to access private data members, which can be used when writing tailored input and output (I\/O) coding in C++ for your class object (reporting) functionality.  Today we write a friend operator overloading scenario for both input and output of our Colour class, which has three data members, the Red, Green and Blue integer colour component parts, commonly referred to as (R,G,B) when you&#8217;re talking in colour <a target=_blank title='The Colour Association' href='http:\/\/www.linkedin.com\/groups\/Color-Association-1994751?home=&#038;gid=1994751&#038;trk=anet_ug_hm'>circles<\/a> &#8230; man.<\/p>\n<blockquote><p>In object-oriented programming, operator overloading\u2014less commonly known as operator ad-hoc polymorphism\u2014is a specific case of polymorphism, where different operators have different implementations depending on their arguments. Operator overloading is generally defined by the language, the programmer, or both.<\/p>\n<p>Operator overloading is claimed to be useful because it allows the developer to program using notation &#8220;closer to the target domain&#8221;[1] and allows user-defined types a similar level of syntactic support as types built into the language. <\/p><\/blockquote>\n<p>Click on picture to see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FriendOverload\/colour_cpp.jpg'>C++ using Xcode<\/a> for this.<\/p>\n<p>Link to some downloadable code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FriendOverload\/main.cpp_GETME' title='Download me'>main.cpp<\/a> for use.<\/p>\n<p>The <a target=_blank title='Useful link ... thanks' href='http:\/\/www.learncpp.com\/cpp-tutorial\/93-overloading-the-io-operators\/'>link<\/a> here was very useful &#8230; thanks a lot.<\/p>\n<p>Link to Operator Overloading information &#8230; <a target=_blank title='Operator Overloading' href='http:\/\/en.wikipedia.org\/wiki\/Operator_overloading'>from Wikipedia from which quote above comes<\/a>.<br \/>\nLink to Function Overloading information &#8230; <a target=_blank title='Function Overloading' href='http:\/\/en.wikipedia.org\/wiki\/Function_overloading'>from Wikipedia<\/a>.<\/p>\n<hr \/>\n<p id='cxomit'>Previous relevant <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=2699' title='C++ Xcode OOP Multiple Inheritance Tutorial'>C++ Xcode OOP Multiple Inheritance Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/OperatorOverloading\/OperatorOverloading.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"C++ Xcode OOP Multiple Inheritance Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/OperatorOverloading\/OperatorOverloading.jpg\" title=\"C++ Xcode OOP Multiple Inheritance Tutorial\"  \/><\/a><p class=\"wp-caption-text\">C++ Xcode OOP Multiple Inheritance Tutorial<\/p><\/div>\n<p>Our  C++ Xcode OOP Operator Overloading Tutorial presented here builds off the previous <a target=_blank title='C++ Xcode OOP Multiple Inheritance Tutorial' href='#pmipid'>C++ Xcode OOP Multiple Inheritance Tutorial<\/a> below.<\/p>\n<blockquote><p>In object-oriented programming, operator overloading\u2014less commonly known as operator ad-hoc polymorphism\u2014is a specific case of polymorphism, where different operators have different implementations depending on their arguments. Operator overloading is generally defined by the language, the programmer, or both.<\/p>\n<p>Operator overloading is claimed to be useful because it allows the developer to program using notation &#8220;closer to the target domain&#8221;[1] and allows user-defined types a similar level of syntactic support as types built into the language. <\/p><\/blockquote>\n<p>Click on picture to see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/OperatorOverloading\/OperatorOverloading.jpg'>C++ using Xcode<\/a> for this, as well as an example of Function Overloading.<\/p>\n<p>Link to some downloadable code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/OperatorOverloading\/main.cpp_GETME' title='Download me'>main.cpp<\/a> for use.<\/p>\n<p>Link to Operator Overloading information &#8230; <a target=_blank title='Operator Overloading' href='http:\/\/en.wikipedia.org\/wiki\/Operator_overloading'>from Wikipedia from which quote above comes<\/a>.<br \/>\nLink to Function Overloading information &#8230; <a target=_blank title='Function Overloading' href='http:\/\/en.wikipedia.org\/wiki\/Function_overloading'>from Wikipedia<\/a>.<\/p>\n<hr \/>\n<p id=\"pmipid\">Previous <a target=_blank title='C++ Xcode OOP Multiple Inheritance Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=1582'>C++ XCode OOP Multiple Inheritance Tutorial<\/a> below:<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/MultiInheritance\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"C++ Xcode OOP Multiple Inheritance Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/MultiInheritance\/MultiInheritance.jpg\" title=\"C++ Xcode OOP Multiple Inheritance Tutorial\"  \/><\/a><p class=\"wp-caption-text\">C++ Xcode OOP Multiple Inheritance Tutorial<\/p><\/div>\n<p>Here is a programming tutorial that introduces you to some more aspects of OOP &#8230; oops, forgot to say what OOP stands for &#8230; Object Oriented Programming &#8230; specifically regarding <a target=_blank title='Multiple Inheritance as discussed by Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Multiple_inheritance'>Multiple Inheritance<\/a>.<\/p>\n<blockquote><p>Object-oriented programming (OOP) is a programming paradigm that represents concepts as &#8220;objects&#8221; that have data fields (attributes that describe the object) and associated procedures known as methods. Objects, which are usually instances of classes, are used to interact with one another to design applications and computer programs.<\/p><\/blockquote>\n<p>To me, the beauty of OOP is that it can relate to the nouns in our life.   Think of an object that you can touch, like a wristwatch &#8230; it has features like its type of design, its size, its weight (ie. its properties), and it has objects that go to make it up, like cogs and wheels (ie. its components), and it has its related classes of objects like clock, alarm clock, oven timer etcetera (ie. its characteristics), and its more fundamental essence, the class of watch (ie. its inheritance).<\/p>\n<p>In this tutorial we touch on Multiple Inheritance by the way one class can inherit from more than one other class.<\/p>\n<p>Let&#8217;s see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/MultiInheritance\/'>C++ using XCode<\/a> for this &#8230;<\/p>\n<p>Link to Object Oriented Programming information &#8230; <a target=_blank title='OOP' href='http:\/\/en.wikipedia.org\/wiki\/Object-oriented_programming'>from Wikipedia from which quote just above comes<\/a>.<br \/>\nLink to Object Oriented Programming inventor information &#8230; <a target=_blank href='http:\/\/en.wikipedia.org\/wiki\/Kristen_Nygaard' title='Object Oriented Programming inventor ... thanks to Wikipedia, again.'>Kristen Nygaard<\/a>.<br \/>\nAlso like this <a target=_blank title='Multi-Inheritance tutorial by Well House Consultants Ltd.' href='http:\/\/www.wellho.net\/resources\/ex.php4?item=c233\/petite.cpp'>link<\/a> with regard to Multiple Inheritance.<br \/>\nLink to some downloadable code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/MultiInheritance\/main.cpp_GETME' title='Download me'>main.cpp<\/a> for use.\n<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d1582' onclick='var dv=document.getElementById(\"d1582\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=C%2B%2B\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d1582' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d2699' onclick='var dv=document.getElementById(\"d2699\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=C%2B%2B\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d2699' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d9944' onclick='var dv=document.getElementById(\"d9944\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=OOP\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d9944' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>10 <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/c-xcode-oop-friend-overload-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,12,28,37,40],"tags":[176,704,875,1837,1836,997,1319,1473],"class_list":["post-9944","post","type-post","status-publish","format-standard","hentry","category-colour-matching","category-elearning","category-oop","category-tutorials","category-xcode","tag-c","tag-linkedin","tag-oop","tag-overload","tag-override","tag-programming","tag-tutorial","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/9944"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=9944"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/9944\/revisions"}],"predecessor-version":[{"id":20913,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/9944\/revisions\/20913"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=9944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=9944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=9944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}