<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>MFC Info</title><description>To help each other MFC developer</description><managingEditor>noreply@blogger.com (Anil)</managingEditor><pubDate>Sat, 28 Sep 2024 12:21:45 -0700</pubDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">23</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><link>http://mfcmisc.blogspot.com/</link><language>en-us</language><itunes:explicit>yes</itunes:explicit><itunes:subtitle>This blog will be useful for C/C++/VC++/C#/MFC Developer</itunes:subtitle><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><title>Qt 4.5 with Visual Studio 2008 (VC++ Express)</title><link>http://mfcmisc.blogspot.com/2009/07/qt-45-with-visual-studio-2008-vc.html</link><category>VC++ info</category><author>noreply@blogger.com (Anil)</author><pubDate>Thu, 23 Jul 2009 03:05:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-2378196536623041990</guid><description>&lt;p&gt;&lt;a href="http://www.qtsoftware.com/" target="_blank"&gt;Qt&lt;/a&gt; is a cross platform GUI toolkit from Nokia. Its SDK is available under an LPGL license, it means we can use it free of charge to develop proprietary, commercial, closed-source software (thanks to Nokia).  However, the current LPGL release leaves some gaps in using Qt from within Visual Studio 2008. This is somewhat understandable given that Visual Studio integration was a commercial-only offering and Nokia has Qt Creator (and not Visual Studio).  My problem with &lt;strong&gt;Qt Creator&lt;/strong&gt; is it uses &lt;strong&gt;MingGW&lt;/strong&gt; (gcc) compiler which is nowhere near as good as VC++ 2008.  Also for Visual Studio background like me, who is not familiar with Qt creator, learning Qt Creator will take time. Thanks to &lt;a href="http://geeks.netindonesia.net/blogs/lontong"&gt;Wiria&lt;/a&gt; and &lt;a href="http://geeks.netindonesia.net/blogs/agus/"&gt;AK&lt;/a&gt; who brought Qt to my table for a review.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Qt GUI Toolkit is very useful to develop portable application (single source codes) for *NIX, MAC and Windows (including Windows 98 but not being tested for Windows 7).  In this post, I will show you how to start using Qt SDK only with Visual C++ 2008, you can use FREE Visual C++ 2008 express too.&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style="color:#000080;"&gt;Build VC++ Version of Qt&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;  - Download and install &lt;a href="http://www.qtsoftware.com/downloads/sdk-windows-cpp" target="_blank"&gt;qt-sdk-win-opensource-2009.01.1&lt;/a&gt;.    &lt;br /&gt;- Install the SDK to default directory, in my case C:\qt\2009.01. I didn;t install MingGW and Qt Creator as I don’t need.&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>C/C++/VC++ Interview Questions: Part 5</title><link>http://mfcmisc.blogspot.com/2009/04/ccvc-interview-questions-part-5.html</link><category>C</category><category>C++</category><category>VC++</category><author>noreply@blogger.com (Anil)</author><pubDate>Tue, 14 Apr 2009 02:13:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-6856485005375445532</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q : What is a heap ?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ans : Heap is a chunk of memory. When in a program memory is allocated dynamically, the C run-time library gets the memory from a collection of unused memory called the heap. The heap resides in a program's data segment. Therefore, the amount of heap space available to the program is fixed, and can vary from one program to another.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q : How to obtain a path of the given file?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ans: The function searchpath( ) searches for the specified file in the subdirectories of the current path. Following program shows how to &lt;/span&gt;&lt;/span&gt;&lt;a style="background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;" name="AdBriteInlineAd_make" id="AdBriteInlineAd_make" target="_top"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;make&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; use of the searchpath( ) function. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include "dir.h"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;void main ( int argc, char *argv[] )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;char *path ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;if ( path = searchpath ( argv[ 1 ] ) )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;printf ( "Pathname : %s\n", path ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;printf ( "File not found\n" ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q : Can we get the process identification &lt;/span&gt;&lt;/span&gt;&lt;a style="background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;" name="AdBriteInlineAd_number" id="AdBriteInlineAd_number" target="_top"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;number&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; of the current program?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ans: Yes! The macro getpid( ) gives us the process identification number of the program currently running. The process id. uniquely identifies a program. Under DOS, the getpid( ) returns the Program Segment Prefix as the process id. Following program illustrates the use of this macro. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;process.h&gt;&lt;/process.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;void main( )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{ &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;printf ( "The process identification number of this program is %X\n", &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;getpid( ) ) ; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q : How do I write a function that takes variable number of arguments?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ans: The following program demonstrates this. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;stdarg.h&gt;&lt;/stdarg.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;void main( )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{ &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;int i = 10 ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;float f = 2.5 ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;char *str = "Hello!" ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;vfpf ( "%d %f %s\n", i, f, str ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;vfpf ( "%s %s", str, "Hi!" ) ; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;void vfpf ( char *fmt, ... )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{ &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;va_list argptr ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;va_start ( argptr, fmt ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;vfprintf ( stdout, fmt, argptr ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;va_end ( argptr ) ; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Here, the function vfpf( ) has called vfprintf( ) that take variable argument lists. va_list is an array that holds information required for the macros va_start and va_end. The macros va_start and va_end provide a portable way to access the variable argument lists. va_start would set up a pointer argptr to point to the first of the variable arguments being passed to the function. The macro va_end &lt;/span&gt;&lt;/span&gt;&lt;a style="background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;" name="AdBriteInlineAd_helps" id="AdBriteInlineAd_helps" target="_top"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;helps&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; the called function to perform a normal return.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q : Can we change the system date to some other date?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ans: Yes, We can! The function stime( ) sets the system date to the specified date. It also sets the system time. The time and date is measured in &lt;/span&gt;&lt;/span&gt;&lt;a style="background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;" name="AdBriteInlineAd_seconds" id="AdBriteInlineAd_seconds" target="_top"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;seconds&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; from the 00:00:00 GMT, January 1, 1970. The following program shows how to use this function. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;time.h&gt;&lt;/time.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;void main( )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{ &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a style="background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;" name="AdBriteInlineAd_time_t" id="AdBriteInlineAd_time_t" target="_top"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;time_t&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; tm ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;int d ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;tm = time ( NULL ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;printf ( "The System Date : %s", ctime ( &amp;amp;tm ) ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;printf ( "\nHow many days ahead you want to set the date : " ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;scanf ( "%d", &amp;amp;d ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;tm += ( 24L * d ) * 60L * 60L ; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;stime ( &amp;amp;tm ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;printf ( "\nNow the new date is : %s", ctime ( &amp;amp;tm ) ) ; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;} &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In this program we have used function ctime( ) in addition to function stime( ). The ctime( ) function converts time value to a 26-character long &lt;/span&gt;&lt;/span&gt;&lt;a style="background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;" name="AdBriteInlineAd_string" id="AdBriteInlineAd_string" target="_top"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; that contains date and time.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q : How to use function strdup( ) in a program?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ans : The string function strdup( ) copies the given string to a new location. The function uses malloc( ) function to allocate space required for the duplicated string. It takes one argument a pointer to the string to be duplicated. The total number of characters present in the given string plus one bytes get allocated for the new string. As this function uses malloc( ) to allocate memory, it is the programmer’s responsibility to deallocate the memory using free( ). &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;string.h&gt;&lt;/string.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;alloc.h&gt;&lt;/alloc.h&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;void main( )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{ &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;char *str1, *str2 = "double";&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;str1 = strdup ( str2 ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;printf ( "%s\n", str1 ) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;free ( str1 ) ; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q : On including a file twice I get errors reporting redefinition of function. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;How can I avoid duplicate inclusion?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ans: Redefinition errors can be avoided by using the following macro definition. Include this definition in the header file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#if !defined filename_h&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#define filename_h&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;/* function definitions */&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Replace filename_h with the actual header file &lt;/span&gt;&lt;/span&gt;&lt;a style="background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;" name="AdBriteInlineAd_name" id="AdBriteInlineAd_name" target="_top"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;name&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;. For example, if name of file to be included is 'goto.h' then replace filename_h &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q : How to write a swap( ) function which swaps the values of the variables using bitwise operators.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ans: Here is the swap( ) function.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;swap ( int *x, int *y )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;*x ^= *y ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;*y ^= *x ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;*x ^= *y ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The swap( ) function uses the bitwise XOR operator and does not require any temporary variable for swapping.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>C/C++/VC++ Interview Questions: Part 4</title><link>http://mfcmisc.blogspot.com/2009/04/ccvc-interview-questions-part-4.html</link><category>C</category><category>C++</category><category>VC++</category><author>noreply@blogger.com (Anil)</author><pubDate>Tue, 14 Apr 2009 02:11:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-1428043477312150539</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. Name some pure object oriented languages.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Smalltalk,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Java,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Eiffel,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Sather.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. Name the operators that cannot be overloaded.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;sizeof . .* .-&gt; :: ?:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a node class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;A node class is a class that,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; relies on the base class for services and implementation,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; provides a wider interface to te users than its base class,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; relies primarily on virtual functions in its public interface&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; depends on all its direct and indirect base class&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; can be understood only in the context of the base class&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; can be used as base for further derivation&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; can be used to create objects.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;A node class is a class that has added new services or functionality beyond the services inherited from its base class.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is an orthogonal base class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: If two base classes have no overlapping methods or data they are said to be independent of, or orthogonal to each other. Orthogonal in the sense means that two classes operate in different dimensions and do not interfere with each other in any way. The same derived class may inherit such classes with no difficulty.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a container class? What are the types of container classes?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a protocol class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: An abstract class is a protocol class if:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; it neither contains nor inherits from classes that contain member data, non-virtual functions, or private (or protected) members of any kind.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; it has a non-inline virtual destructor defined with an empty implementation,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; all member functions other than the destructor including inherited functions, are declared pure virtual functions and left undefined.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a mixin class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A class that provides some but not all of the implementation for a virtual base class is often called mixin. Derivation done just for the purpose of redefining the virtual functions in the base classes is often called mixin inheritance. Mixin classes typically don't share common bases.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a concrete class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A concrete class is used to define a useful object that can be instantiated as an automatic variable on the program stack. The implementation of a concrete class is defined. The concrete class is not intended to be a base class and no attempt to minimize dependency on other classes in the implementation or behavior of the class.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q.What is the handle class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A handle is a class that maintains a pointer to an object that is programmatically accessible through the public interface of the handle class.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Explanation:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In case of abstract classes, unless one manipulates the objects of these classes through pointers and references, the benefits of the virtual functions are lost. User code may become dependent on details of implementation classes because an abstract type cannot be allocated statistically or on the stack without its size being known. Using pointers or references implies that the burden of memory management falls on the user. Another limitation of abstract class object is of fixed size. Classes however are used to represent concepts that require varying amounts of storage to implement them.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;A popular technique for dealing with these issues is to separate what is used as a single object in two parts: a handle providing the user interface and a representation holding all or most of the object's state. The connection between the handle and the representation is typically a pointer in the handle. Often, handles have a bit more data than the simple representation pointer, but not much more. Hence the layout of the handle is typically stable, even when the representation changes and also that handles are small enough to move around relatively freely so that the user needn’t use the pointers and the references.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is an action class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: The simplest and most obvious way to specify an action in C++ is to write a function. However, if the action has to be delayed, has to be transmitted 'elsewhere' before being performed, requires its own data, has to be combined with other actions, etc then it often becomes attractive to provide the action in the form of a class that can execute the desired action and provide other services as well. Manipulators used with iostreams is an obvious example.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Explanation:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;A common form of action class is a simple class containing just one virtual function.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;class Action&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;public:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;virtual int do_it( int )=0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;virtual ~Action( );&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Given this, we can write code say a member that can store actions for later execution without using pointers to functions, without knowing anything about the objects involved, and without even knowing the name of the operation it invokes. For example:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;class write_file : public Action&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;File&amp;amp; f;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;public:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;int do_it(int)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;return fwrite( ).suceed( );&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;class error_message: public Action&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;response_box db(message.cstr( ),"Continue","Cancel","Retry");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;switch (db.getresponse( ))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;case 0: return 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;case 1: abort();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;case 2: current_operation.redo( );return 1;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;A user of the Action class will be completely isolated from any knowledge of derived classes such as write_file and error_message.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>C/C++/VC++ Interview Questions: Part 3</title><link>http://mfcmisc.blogspot.com/2009/04/ccvc-interview-questions-part-3.html</link><category>C</category><category>C++</category><category>MFC</category><category>VC++</category><author>noreply@blogger.com (Anil)</author><pubDate>Tue, 14 Apr 2009 02:11:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-5953769109393732449</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is an incomplete type?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: Incomplete types refers to pointers in which there is non availability of the implementation of the referenced location or it points to some location whose value is not available for modification.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Example:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;int *i=0x400 // i points to address 400&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;*i=0; //set the value of memory location pointed by i.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Incomplete types are otherwise called uninitialized pointers.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a dangling pointer?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A dangling pointer arises when you use the address of an object after its lifetime is over. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. Differentiate between the message and method.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Message Method&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Objects communicate by sending messages Provides response to a message.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;to each other.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;A message is sent to invoke a method. It is an implementation of an operation.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is an adaptor class or Wrapper class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non- object- oriented implementation.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a Null object?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a Null object?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is class invariant?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, and they must be preserved under all operations of the class. In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What do you mean by Stack unwinding?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. Define precondition and post-condition to a member function.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Precondition: A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Post-condition: A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What are the conditions that have to be met for a condition to be an invariant of the class?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; The condition should hold at the end of every constructor.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; The condition should hold at the end of every mutator(non-const) operation.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What are proxy objects?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Objects that stand for other objects are called proxy objects or surrogates.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Example:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;template&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;class Array2D&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;public:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;class Array1D&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;public:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;T&amp;amp; operator[] (int index);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;const T&amp;amp; operator[] (int index) const;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Array1D operator[] (int index);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;const Array1D operator[] (int index) const;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The following then becomes legal:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Array2Ddata(10,20);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;........&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>C/C++/VC++ Interview Questions: Part 2</title><link>http://mfcmisc.blogspot.com/2009/04/ccvc-interview-questions-part-2.html</link><category>C</category><category>C++</category><category>VC++</category><author>noreply@blogger.com (Anil)</author><pubDate>Tue, 14 Apr 2009 01:54:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-2161215861235297120</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is a modifier?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A modifier, also called a modifying function is a member function that changes the value of at least one data member. In other words, an operation that modifies the state of an object. Modifiers are also known as ‘mutators’.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is an accessor?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: An accessor is a class operation that does not modify the state of an object. The accessor functions need to be declared as const operations&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. Differentiate between a template class and class template.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Template class: A generic definition or a parameterized class not instantiated until the client provides the needed information. It’s jargon for plain templates.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Class template: A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It’s jargon for plain classes.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. When does a name clash occur?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A name clash occurs when a name is defined in more than one place. For example., two different class libraries could give two different classes the same name. If you try to use many class libraries at the same time, there is a fair chance that you will be unable to compile or link the program because of name clashes.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. Define namespace.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: It is a feature in c++ to minimize name collisions in the global name space. This namespace keyword assigns a distinct name to a library that allows other libraries to use the same identifier names without creating any name collisions. Furthermore, the compiler uses the namespace signature for differentiating the definitions.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is the use of ‘using’ declaration.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A using declaration makes it possible to use a name from a namespace without the scope operator.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. What is an Iterator class?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer: A class that is used to traverse through the objects maintained by a container class.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;There are five categories of iterators:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; input iterators,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; output iterators,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; forward iterators,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; bidirectional iterators,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; random access.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;An iterator is an entity that gives access to the contents of a container object without violating encapsulation constraints. Access to the contents is granted on a one-at-a-time basis in order. The order can be storage order (as in lists and queues) or some arbitrary order (as in array indices) or according to some ordering relation (as in an ordered binary tree). The iterator is a construct, which provides an interface that, when called, yields either the next element in the container, or some value denoting the fact that there are no more elements to examine. Iterators hide the details of access to and update of the elements of a container class.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The simplest and safest iterators are those that permit read-only access to the contents of a container class. The following code fragment shows how an iterator might appear in code:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;cont_iter:=new cont_iterator();&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;x:=cont_iter.next();&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;while x/=none do&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;...&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;s(x);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;...&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;x:=cont_iter.next();&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;end;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In this example, cont_iter is the name of the iterator. It is created on the first line by instantiation of cont_iterator class, an iterator class defined to iterate over some container class, cont. Succesive elements from the container are carried to x. The loop terminates when x is bound to some empty value. (Here, none)In the middle of the loop, there is s(x) an operation on x, the current element from the container. The next element of the container is obtained at the bottom of the loop.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. List out some of the OODBMS available.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; GEMSTONE/OPAL of Gemstone systems.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; ONTOS of Ontos.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Objectivity of Objectivity inc.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Versant of Versant object technology.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Object store of Object Design.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; ARDENT of ARDENT software.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; POET of POET software.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Q. List out some of the object-oriented methodologies.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Answer:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Object Oriented Development (OOD) (Booch 1991,1994).&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Object Oriented Analysis and Design (OOA/D) (Coad and Yourdon 1991).&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Object Modelling Techniques (OMT) (Rumbaugh 1991).&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Object Oriented Software Engineering (Objectory) (Jacobson 1992).&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; Object Oriented Analysis (OOA) (Shlaer and Mellor 1992).&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; The Fusion Method (Coleman 1991).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>C/C++/VC++ Interview Questions: Part 1</title><link>http://mfcmisc.blogspot.com/2009/04/ccvc-interview-questions-part-1.html</link><category>C</category><category>C++</category><category>copy Constructor</category><category>VC++</category><category>Virtual Destructor</category><author>noreply@blogger.com (Anil)</author><pubDate>Tue, 14 Apr 2009 01:27:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-8800672719173285436</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: There is nothing like Virtual Constructor. The constructor can’t be virtual as the constructor is a code which is responsible for creating an instance of a class and it can’t be delegated to any other object by virtual keyword means.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What is Constructor ?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: Constructor creates an object and initializes it. It also creates V-Table for virtual functions. It is different from other methods in a class.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What about Virtual Destructor?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime depending on the type of object caller is calling to, proper destructor will be called.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What is the difference between a copy constructor and an overloaded assignment operator?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: Can a constructor throws an exception? How to handle the error when the constructor fails?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: The constructor never throws an error.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What is default constructor?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: Constructor with no arguments or all the arguments has default values.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What is default (Implicit) copy constructor?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: Constructor which initializes it's object member variables (by shallow copying) with another object of the same class. If you don't implement one in your class then compiler implements one for you.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Examples:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(a) Boo Obj1(10); // calling Boo constructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(b) Boo Obj2(Obj1); // calling boo copy constructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(c) Boo Obj2 = Obj1;// calling boo copy constructor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: When is copy constructors called?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: Copy constructors are called in following cases:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(a) When a function returns an object of that class by value&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(b) When the object of that class is passed by value as an argument to a function&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(c) When you construct an object based on another object of the same class&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(d) When compiler generates a temporary object&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What is conversion constructor?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: constructor with a single argument makes that constructor as conversion ctor and it can be used for type conversion.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Example:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;class Boo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Boo( int i );&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Boo BooObject = 10 ; // assigning int 10 Boo object&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q:What is conversion operator??&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A:class can have a public method for specific data type conversions.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;For example:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;class Boo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;double value;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Boo(int i )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;operator double()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;return value;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Boo BooObject;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;double i = BooObject; // assigning object to variable i of type double. now conversion operator gets called to assign the value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: How can I handle a constructor that fails?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: throw an exception. Constructors don't have a return type, so it's not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: How can I handle a destructor that fails?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: Write a message to a log-_le. But do not throw an exception. The C++ rule is that you must never throw an exception from a destructor that is being called during the "stack unwinding" process of another exception. For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get popped. This is called stack unwinding. During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a } catch (Bare) { handler? There is no good answer:either choice loses information. So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you're dead.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What is Virtual Destructor?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: Using virtual destructors, you can destroy objects without knowing their type - the correct destructor for the object is invoked using the virtual function mechanism. Note that destructors can also be declared as pure virtual functions for abstract classes. if someone will derive from your class, and if someone will say "new Derived", where "Derived" is derived from your class, and if someone will say delete p, where the actual object's type is "Derived" but the pointer p's type is your class.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What's the order that local objects are destructed?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: In reverse order of construction: First constructed, last destructed. In the following example, b's destructor will be executed first, then a's destructor:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;void userCode()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Fred a;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Fred b;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Q: What's the order that objects in an array are destructed?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A: In reverse order of construction: First constructed, last destructed. In the following example, the order for destructors will be a[9], a[8], ..., a[1], a[0]:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;void userCode()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Fred a[10];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>C++ Portability Rules - 1</title><link>http://mfcmisc.blogspot.com/2009/04/c-portability-rules-1.html</link><author>noreply@blogger.com (Anil)</author><pubDate>Wed, 8 Apr 2009 04:58:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-2600909961758585076</guid><description>&lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;8. Use the common denominator between members of a C/C++ compiler family&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;For many of the compiler families we use, the implementation of the C and C++ compilers are completely different, sometimes this means that there are things you can do in the C language, that you cannot do in the C++ language on the same machine. One example is the 'long long' type. On some systems (IBM's compiler used to be one, but I think it's better now), the C compiler supports long long, while the C++ compiler does not. This can make porting a pain, as often times these types are in header files shared between C and C++ files. The only thing you can do is to go with the common denominator that both compilers support. In the special case of long long, we developed a set of macros for supporting 64 bit integers when the long long type is not available. We have to use these macros if either the C or the C++ compiler does not support the special 64 bit type. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;9. Don't put C++ comments in C code.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The quickest way to raise the blood pressure of a Netscape Unix engineer is to put C++ comments (// comments) into C files. Yes, this might work on your Microsoft Visual C compiler, but it's wrong, and is not supported by the vast majority of C compilers in the world. Just do not go there. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Many header files will be included by C files and included by C++ files. We think it's a good idea to apply this same rule to those headers. Don't put C++ comments in header files included in C files. You might argue that you could use C++ style comments inside #ifdef __cplusplus blocks, but we are not convinced that is always going to work (some compilers have weird interactions between comment stripping and pre-processing), and it hardly seems worth the effort. Just stick to C style /**/ comments for any header file that is ever likely to be included by a C file. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;10. Don't put carriage returns in XP code. &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;While this is not specific to C++, we have seen this as more of an issue with C++ compilers, see Use the common denominator between members of a C/C++ compiler family. In particular, it causes bustage on at least the IRIX native compiler.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;On unix systems, the standard end of line character is line feed ('\n'). The standard on many PC editors is carriage return and line feed ("\r\n"), while the standard on Mac is carriage return ("\r"). The PC compilers seem to be happy either way, but some Unix compilers just choke when they see a carriage return (they do not recognize the character as white space). So, we have a rule that you cannot check in carriage returns into any cross platform code. This rule is not enforced on the Windows front end code, as that code is only ever compiled on a PC. The Mac compilers seem to be happy either way, but the same rule applies as for the PC - no carriage returns in cross platform code.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;MacCVS, WinCVS, and cygwin CVS when configured to use DOS line endings automatically convert to and from platform line endings, so you don't need to worry. However, if you use cygwin CVS configured for Unix line endings, or command line cvs on Mac OS X, you need to be somewhat careful.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;11. Put a new line at end-of-file.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Not having a new-line char at the end of file breaks .h files with the Sun WorkShop compiler and it breaks .cpp files on HP. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;12. Don't put extra top-level semi-colons in code.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Non-portable example: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  int&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  A::foo()&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  };&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;This is another problem that seems to show up more on C++ than C code. This problem is really a bit of a drag. That extra little semi-colon at the end of the function is ignored by most compilers, but it is not permitted by the standard and it makes some compilers report errors (in particular, gcc 3.4, and also perhaps old versions of the AIX native compiler). Don't do it. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Portable example: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  int&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  A::foo()&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;13. C++ filename extension is .cpp.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;This one is another plain annoying problem. What's the name of a C++ file? file.cpp, file.cc, file.C, file.cxx, file.c++, file.C++? Most compilers could care less, but some are very particular. We have not been able to find one file extension which we can use on all the platforms we have ported Mozilla code to. For no &lt;/span&gt;&lt;a name="AdBriteInlineAd_great"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;great&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; reason, we've settled on file.cpp, probably because the first C++ code in Mozilla code was checked in with that extension. Well, it's done. The extension we use is .cpp. This extension seems to &lt;/span&gt;&lt;a name="AdBriteInlineAd_make"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;make&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; most compilers happy, but there are some which do not like it. On those systems we have to &lt;/span&gt;&lt;a name="AdBriteInlineAd_create"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;create&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; a wrapper for the compiler (see STRICT_CPLUSPLUS_SUFFIX in ns/config/rules.mk and ns/build/*), which actually copies the file.cpp file to another file with the correct extension, compiles the new file, then deletes it. If in porting to a new system, you have to do something like this, make sure you use the #line directive so that the compiler generates debug information relative to the original .cpp file. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;14. Don't mix varargs and inlines. &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Non-portable example: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  class FooBar {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    void va_inline(char* p, ...) {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;      // something&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  };&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The subject says it all, varargs and inline functions do not seem to mix very well. If you must use varargs (which can cause portability &lt;/span&gt;&lt;a name="AdBriteInlineAd_problems"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;problems&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; on their own), then ensure that the vararg member function is a non-inline function. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Portable example: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  // foobar.h&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  class FooBar {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;      void &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span style="mso-spacerun:yes"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;va_non_inline(char* p, ...);&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  };&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  // foobar.cpp&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  void &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  FooBar::va_non_inline(char* p, ...)&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span style="mso-spacerun:yes"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;// something&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;15. Don't use initializer lists with objects.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Non-portable example: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  FooClass myFoo = {10, 20};&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Some compilers won't allow this syntax for objects (HP-UX won't), actually only some will allow it. So don't do it. Again, use a wrapper function, see Don't use static constructors. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Always have a default constructor. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Always have a default constructor, even if it doesn't make sense in terms of the object structure/hierarchy. HP-UX will barf on statically initialized objects that don't have default constructors. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>C++ Portability Rules</title><link>http://mfcmisc.blogspot.com/2009/04/c-portability-rules.html</link><author>noreply@blogger.com (Anil)</author><pubDate>Wed, 8 Apr 2009 04:41:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-6998854711538841955</guid><description>&lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;1. Be very careful when writing C++ templates. &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Don't use C++ templates unless you do only things already known to be portable because they are already used in Mozilla (such as patterns used by nsCOMPtr or CallQueryInterface) or are willing to test your code carefully on all of the compilers we support and be willing to back it out if it breaks. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;2. Don't use static constructors.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Non-portable example: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  FooBarClass static_object(87, 92);&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  void&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  bar()&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    if (static_object.count &gt; 15) {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;       ...&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Static constructors don't work reliably either. A static initialized object is an object which is instanciated at startup time (just before main() is called). Usually there are two components to these objects. First there is the data segment which is static data loaded into the global data segment of the program. The second part is a initializer function that is called by the loader before main() is called. We've found that many compilers do not reliably implement the initializer function. So you get the object data, but it is never initialized. One workaround for this limitation is to write a wrapper function that creates a single instance of an object, and replace all references to the static initialized object with a call to the wrapper function: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Portable example: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  static FooBarClass* static_object;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  FooBarClass*&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  getStaticObject()&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    if (!static_object)&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;      static_object = &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span style="mso-spacerun:yes"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;new FooBarClass(87, 92);&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    return static_object;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  void&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  bar()&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    if (getStaticObject()-&gt;count &gt; 15) {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;      ...&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;3. Don't use exceptions.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Exceptions are another C++ feature which is not very widely implemented, and as such, their use is not portable C++ code. Don't use them. Unfortunately, there is no good workaround that produces similar functionality. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;One exception to this rule (don't say it) is that it's probably ok, and may be necessary to use exceptions in some machine specific code. If you do use exceptions in machine specific code you must catch all exceptions there because you can't throw the exception across XP (cross platform) code. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;4. Don't use Run-time Type Information.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Run-time type information (RTTI) is a relatively new C++ feature, and not supported in many compilers. Don't use it. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;If you need runtime typing, you can achieve a similar result by adding a classOf() virtual member function to the base class of your hierarchy and overriding that member function in each subclass. If classOf() returns a unique value for each class in the hierarchy, you'll be able to do type comparisons at runtime. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;5. Don't use C++ standard library features, including iostream&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Using C++ standard library features involves significant portability problems because newer compilers require the use of namespaces and of headers without .h, whereas older compilers require the opposite. This includes iostream features, such as cin and cout.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Furthermore, using the C++ standard library imposes difficulties on those attempting to use Mozilla on small devices.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;There is one exception to this rule: it is acceptable to use placement new. To use it, include the standard header by writing #include NEW_H.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;6. Don't use namespace facility.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Support of namespaces (through the namespace and using keywords) is a relatively new C++ feature, and not supported in many compilers. Don't use it. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;7. main() must be in a C++ file.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The first C++ compiler, Cfront, was in fact a very fancy preprocessor for a C compiler. Cfront reads the C++ code, and generates C code that would do the same thing. C++ and C startup sequences are different (for example static constructor functions must be called for C++), and Cfront implements this special startup by noticing the function called "main()", converting it to something else (like "__cpp__main()"), adding another main() that does the special C++ startup things and then calls the original function. Of course for all this to work, Cfront needs to see the main() function, hence main() must be in a C++ file. Most compilers lifted this restriction years ago, and deal with the C++ special initialization duties as a linker issue. But there are a few commercial compilers shipping that are still based on Cfront: HP, and SCO, are examples. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;So the workaround is quite simple. Make sure that main() is in a C++ file. On the Unix version of Mozilla, we did this by adding a new C++ file which has only a few lines of code, and calls the main main() which is actually in a C file. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>C optimisations</title><link>http://mfcmisc.blogspot.com/2009/04/c-optimisations.html</link><category>C</category><category>C++</category><author>noreply@blogger.com (Anil)</author><pubDate>Tue, 7 Apr 2009 04:22:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-1334120872984072384</guid><description>&lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Using array indices&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;If you wished to set a variable to a particular character, depending upon the value of something, you might do this : &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;switch ( queue ) {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;case 0 :   letter = 'W';&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;   break;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;case 1 :   letter = 'S';&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;   break;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;case 2 :   letter = 'U';&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;   break;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;or maybe &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;if ( queue == 0 )&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  letter = 'W';&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;else if ( queue == 1 )&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  letter = 'S';&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;else&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  letter = 'U';&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A neater ( and quicker ) method is to simply use the value as an &lt;/span&gt;&lt;a name="AdBriteInlineAd_index"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;index&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; into a character array, eg. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;static char *classes="WSU";&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;letter = classes[queue];&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;--------------------------------------------------------------------------------&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Aliases&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Consider the following: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;void func1( int *data )&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    int i;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    for(i=0; i&lt;10;&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;   {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;           somefunc2( *data, i);&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Even though "*data" may never change, the compiler does not know that somefunc2() did not alter it, and so the &lt;/span&gt;&lt;a name="AdBriteInlineAd_program"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;program&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; must read it from memory each &lt;/span&gt;&lt;a name="AdBriteInlineAd_time"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;time&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; it is used - it may be an alias for some other variable that is altered elsewhere. If you know it won't be altered, you could code it like this instead: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;void func1( int *data )&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    int i;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    int localdata;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    localdata = *data;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    for(i=0; i&lt;10;&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    {&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;           somefunc2( localdata, i);&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    }&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;This gives the compiler better opportunity for optimisation. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;--------------------------------------------------------------------------------&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Integers&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Use unsigned ints instead of ints if you know the value will never be negative. Some processors can handle unsigned integer arithmetic considerably faster than signed ( this is also good practise, and &lt;/span&gt;&lt;a name="AdBriteInlineAd_helps"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;helps&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;a name="AdBriteInlineAd_make"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;make&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; for self-documenting code). &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;So the best declaration for an int variable in a tight loop would be &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;a name="AdBriteInlineAd_register"&gt;&lt;span style="font-size: 12pt; color: rgb(0, 102, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;register&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span style="mso-bookmark: AdBriteInlineAd_register"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; unsigned int   var_name;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;(although it is not guaranteed that the compiler will take any &lt;/span&gt;&lt;a name="AdBriteInlineAd_notice"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;notice&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; of "register", and "unsigned" may make no difference to the processor.) &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;text-align: justify;line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Remember, integer arithmetic is much faster than floating-point arithmetic, as it can be usually be done directly by the processor, rather than relying on external FPUs or floating point maths libraries. If you only need to be accurate to two decimal places (e.g. in a simple accounting package), scale everything up by 100, and convert it back to floating point as late as possible.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal"&gt;&lt;span style="font-size: 12pt; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Loop jamming&lt;br /&gt;&lt;br /&gt;Never use two loops where one will suffice:&lt;br /&gt;for(i=0; i&lt;100; i++)&lt;br /&gt;{&lt;br /&gt;stuff();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;for(i=0; i&lt;100; i++)&lt;br /&gt;{&lt;br /&gt;morestuff();&lt;br /&gt;}&lt;br /&gt;It would be better to do:&lt;br /&gt;for(i=0; i&lt;100; i++)&lt;br /&gt;{&lt;br /&gt;stuff();&lt;br /&gt;morestuff();&lt;br /&gt;}&lt;br /&gt;Note, however, that if you do a lot of work in the loop, it might not &lt;/span&gt;  &lt;a name="AdBriteInlineAd_fit"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;fit&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; into your processor's instruction cache. In this case, two separate loops may actually be faster as each one can run completely in the cache.&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Faster for() loops&lt;br /&gt;&lt;br /&gt;Simple but effective.&lt;br /&gt;Ordinarily, you would code a simple for() loop like this:&lt;br /&gt;for( i=0; i&lt;10; i++){ ... }&lt;br /&gt;i loops through the values 0,1,2,3,4,5,6,7,8,9&lt;br /&gt;If you don't care about the &lt;/span&gt;   &lt;a name="AdBriteInlineAd_order"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;order&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; of the loop counter, you can do this instead:&lt;br /&gt;&lt;br /&gt;for( i=10; i--; ) { ... }&lt;br /&gt;Using this code, i loops through the values 9,8,7,6,5,4,3,2,1,0, and the loop should be faster.&lt;br /&gt;This &lt;/span&gt; &lt;a name="AdBriteInlineAd_works"&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;works&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; because it is quicker to process "i--" as the test condition, which says "is i non-zero? If so, decrement it and continue.".&lt;br /&gt;For the original code, the processor has to calculate "subtract i from 10. Is the result non-zero? if so, increment i and continue.". In tight loops, this &lt;/span&gt;&lt;span style="color:#006600"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;make&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; a considerable difference.&lt;br /&gt;The syntax is a little strange, put is perfectly legal. The third statement in the loop is optional (an infinite loop would be written as "for( ; ; )" ). The same effect could also be gained by coding:&lt;br /&gt;&lt;br /&gt;for(i=10; i; i--){}&lt;br /&gt;or (to expand it further)&lt;br /&gt;for(i=10; i!=0; i--){}&lt;br /&gt;The only things you have to be careful of are remembering that the loop stops at 0 (so if you wanted to loop from 50-80, this wouldn't work), and the loop counter goes backwards.It's easy to get caught out if your code relies on an ascending loop counter.&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;switch() instead of if...else...&lt;br /&gt;&lt;br /&gt;For large decisions involving if...else...else..., like this:&lt;br /&gt;if( val == 1)&lt;br /&gt;dostuff1();&lt;br /&gt;else if (val == 2)&lt;br /&gt;dostuff2();&lt;br /&gt;else if (val == 3)&lt;br /&gt;dostuff3();&lt;br /&gt;it may be faster to use a switch:&lt;br /&gt;switch( val )&lt;br /&gt;{&lt;br /&gt;case 1: dostuff1(); break;&lt;br /&gt;&lt;br /&gt;case 2: dostuff2(); break;&lt;br /&gt;&lt;br /&gt;case 3: dostuff3(); break;&lt;br /&gt;}&lt;br /&gt;In the if() statement, if the last case is required, all the previous ones will be tested first. The switch lets us cut out this extra work. If you have to use a big if..else.. statement, test the most likely cases first.&lt;/span&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>MFC Interview Questions &amp; Answers - 3</title><link>http://mfcmisc.blogspot.com/2009/04/mfc-interview-questions-answers-3.html</link><category>MFC</category><author>noreply@blogger.com (Anil)</author><pubDate>Fri, 3 Apr 2009 05:49:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-7989300172315503125</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Que: What is the difference between GetMessage and PeekMessage ?&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans: GetMessage function waits for a message to be placed in the queue before returning where as PeekMessage function does not wait for a message to be placed in the queue before returning.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Que: What’s the difference between PostMessage and SendMessage?&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans: The PostMessage function places (posts) a message in the message queue associated with the thread that created the specified window and then returns without waiting for the thread to process the message.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Que: How to create a model less dialog?&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans: m_pModeless is a variable of type CDialog or any of its descendants.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;m_pModeless-&gt;Create(IDD_DIALOG1, this);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;m_pModeless-&gt;ShowWindow(SW_SHOW); &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;this pointer as a paramter suggest we are creating a child dialog of the current dialog/window.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Que: How to setup a timer?&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans: Use the SetTimer function&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;UINT_PTR SetTimer( HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;TIMERPROC lpTimerFunc );&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;To kill the timer use&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;BOOL KillTimer(int nIDEvent);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Where the nIDEvent is the ID returned by the SetTimer Function.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Que: Name the Synchronization objects ?&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans: Following are the synchronization objects &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;1) Critical Section 2) Event 3) Mutex 4) Semaphore&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Classes provided for above synchronization objects are:&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;1) CCriticalSection 2) CEvent 3) CMutex 4) CSemaphore&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Que: What Is CMutex ?&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans: An object of class CMutex represents a “mutex” — a synchronization object that allows one thread mutually exclusive access to a resource. Mutexes are useful when only one thread at a time can be allowed to modify data or some other controlled resource. For example, adding nodes to a linked list is a process that should only be allowed by one thread at a time. By using a CMutex object to control the linked list, only one thread at a time can gain access to the list.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;To use a CMutex object, construct the CMutex object when it is needed. Specify the name of the mutex you wish to wait on, and that your application should initially own it. You can then access the mutex when the constructor returns. Call CSyncObject::Unlock when you are done accessing the controlled resource.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;An alternative method for using CMutex objects is to add a variable of type CMutex as a data member to the class you wish to control. During construction of the controlled object, call the constructor of the CMutex data member specifying if the mutex is initially owned, the name of the mutex (if it will be used across process boundaries), and desired security attributes.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;To access resources controlled by CMutex objects in this manner, first create a variable of either type CSingleLock or type CMultiLock in your resource’s access member function. Then call the lock object’s Lock member function (for example, CSingleLock::Lock). At this point, your thread will either gain access to the resource, wait for the resource to be released and gain access, or wait for the resource to be released and time out, failing to gain access to the resource. In any case, your resource has been accessed in a thread-safe manner. To release the resource, use the lock object’s Unlock member function (for example, CSingleLock::Unlock), or allow the lock object to fall out of scope&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Que: What is thread &amp;amp; process?&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans: Threads are similar to processes, but differ in the way that they share resources. Threads are distinguished from processes in that processes are typically independent, carry considerable state information and have separate address spaces. Threads typically share the memory belonging to their parent process.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Que: what is the use of AFX_MANAGE_STATE ?&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans: By default, MFC uses the resource handle of the main application to load the resource template. If you have an exported function in a DLL, such as one that launches a dialog box in the DLL, this template is actually stored in the DLL module. You need to switch the module state for the correct handle to be used. You can do this by adding the following code to the beginning of the function:&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;AFX_MANAGE_STATE(AfxGetStaticModuleState( ));&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;This swaps the current module state with the state returned from AfxGetStaticModuleState until the end of the current scope. If all your resources lies in the single DLL you can even change the default handle to the DLL handle with the help of AfxSetResourceHandle function. &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>MFC Interview Questions &amp; Answers - 2</title><link>http://mfcmisc.blogspot.com/2009/04/mfc-interview-questions-answers-2.html</link><category>MFC</category><author>noreply@blogger.com (Anil)</author><pubDate>Fri, 3 Apr 2009 05:48:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-6409797955898370129</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is thread &amp;amp; process?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Threads are similar to processes, but differ in the way that they share resources. Threads are distinguished from processes in that processes are typically independent, carry considerable state information and have separate address spaces. Threads typically share the memory belonging to their parent process.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- what is the use of AFX_MANAGE_STATE ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- By default, MFC uses the resource handle of the main application to load the resource template. If you have an exported function in a DLL, such as one that launches a dialog box in the DLL, this template is actually stored in the DLL module. You need to switch the module state for the correct handle to be used. You can do this by adding the following code to the beginning of the function:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;AFX_MANAGE_STATE(AfxGetStaticModuleState( ));&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;This swaps the current module state with the state returned from AfxGetStaticModuleState until the end of the current scope. If all your resources lies in the single DLL you can even change the default handle to the DLL handle with the help of AfxSetResourceHandle function.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- Why wizards generate enum IDD for dialogs?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- It's good programming practice to do it this way, as from the client code you can always refer to the CMyDlg::IDD without worrying what the actual constant is.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is CArchive class does?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- The CArchive class allows you to save a complex network of objects in a permanent binary form (usually disk storage) that persists after those objects are deleted. Later you can load the objects from persistent storage, reconstituting them in memory. This process of making data persistent is called “serialization.”&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- How to handle command line arguements from simple MFC application ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- m_lpCmdLine Corresponds to the lpCmdLine parameter passed by Windows to WinMain. Points to a null-terminated string that specifies the command line for the application. Use m_lpCmdLine to access any command-line arguments the user entered when the application was started. m_lpCmdLine is a public variable of type LPTSTR.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;BOOL CMyApp::InitInstance()&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;// ...&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;if (m_lpCmdLine[0] == _T('\0'))&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;// Create a new (empty) document.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;OnFileNew();&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;// Open a file passed as the first command line parameter.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;OpenDocumentFile(m_lpCmdLine);&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;// ...&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the base class for MFC Framework ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:-CObject&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- If I derive a new class from CObject what are the basic features my derived will get?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:-Searialization, Debugging support, Runtime time class information, compatibility with collection classes.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the use of CCmdTarget ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- It is the base class for the MFC library message map architecture.Which maps commands/messages to the member functions to handle them. Classes derived from this are CWnd,CWinApp,CFrameWnd,CView, CDocument&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is document-view architecture ? Give me one real time example for SDI ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Document/view architecture, which defines a program structure that relies on document objects to hold an application's data and on view objects to render views of that data. MFC provides the infrastructure for documents and views in the classes CDocument and CView. example of SDI is a wordpad application&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- Can you explain the relashionship between document,frame and view ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- The frame window is the application's top-level window. It's normally a WS_OVERLAPPEDWINDOW-style window with a resizing border, a title bar, a system menu, and minimize, maximize, and close buttons. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The view is a child window sized to fit the frame window so that it becomes the frame window's client area. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The application's data is stored in the document object, a visible representation of which appears in the view. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;For an SDI application, the frame window class is derived from CFrameWnd, the document class is derived from CDocument, and the view class is derived from CView or a related class such as CScrollView.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- How to access document object from view ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Using GetDocument() function within a CView class.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the entry point for window based applications ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- WinMain() is the entry point for window based applications.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- Explain the flow for a simple win32 based application ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Starting point for win32 based applications is WinMain()&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;WinMain begins by calling the API function RegisterClass to register a window class. The window class(WNDCLASS) defines important characteristics of a window such as its window procedure address, its default background color, and its icon. Once the WNDCLASS is registered, WinMain calls the all-important CreateWindow function to create the application's window. WinMain follows CreateWindow with calls to ShowWindow and UpdateWindow, which make the window visible and ensure that its WM_PAINT handler is called immediately. Next comes the message loop. In order to retrieve and dispatch messages, WinMain executes a simple while loop that calls the GetMessage, TranslateMessage, and DispatchMessage API functions repeatedly. GetMessage checks the message queue. If a message is available, it is removed from the queue and copied to msg; TranslateMessage converts a keyboard message denoting a character key to an easier-to-use WM_CHAR message, and DispatchMessage dispatches the message to the window procedure. The message loop executes until GetMessage returns 0, which happens only when a WM_QUIT message is retrieved from the message queue. When this occurs, WinMain ends and the program terminates.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>MFC Interview Questions &amp; Answers - 1</title><link>http://mfcmisc.blogspot.com/2009/04/mfc-interview-questions-answers-1.html</link><category>MFC</category><category>Serialization</category><author>noreply@blogger.com (Anil)</author><pubDate>Fri, 3 Apr 2009 05:46:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-7614724335053282251</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is model and modeless dialog box ? Give some examples?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- When we create Modal Dialog Box we can't move to other windows until this dialog is closed. For eg: MessageBox, where we can't move to the other window until we press ok or cancel. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;When we create Modeless Dilaog Box we can swap to the other windows. For eg: like a conventional window.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- How to create open &amp;amp; save dialogs ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- In CommonDialogs class we have to use CFileDialog class where the first parameter TRUE for open dialog and FALSE for Save dialog.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;For file open:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;CFileDialog SampleDlg(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"Text Files (*.txt)|*.txt|Comma Separated Values(*.csv)|*.csv||");&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;int iRet = SampleDlg.DoModal();&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is CSingleDocTemplate?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- It’s a document template class used to create single document interface SDI applications. Only one document can be opened at a time. It identifies the document class used to manage the application's data, the frame window class that encloses views of that data, and the view class used to draw visual representations of the data. The document template also stores a resource ID that the framework uses to load menus, accelerators, and other resources that shape the application's user interface.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the difference between hinstance and hprevinstance in WinMain function?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- hInstance is used for things like loading resources and any other task which is performed on a per-module basis. A module is either the EXE or a DLL loaded into your program. hPrevInstance used to be the handle to the previously run instance of your program (if any) in Win16. It is always NULL for Win32 programs.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- Explain about MDI and CMultiDocTemplate ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- MDI applications are designed using the doc-view architectures in which there could be many views associated with a single document object and an application can open multiple docuements at the same time for eg:WORD.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;In MDI terms, your main window is called the Frame, this is probably the only window you would have in a SDI (Single Document Interface) program. In MDI there is an additional window, called the MDI Client Window which is a child of your Frame window. CMultiDocTemplate is the document template class used to create MDI applications..The document template also stores a resource ID that the framework uses to load menus, accelerators, and other resources that shape the application's user interface.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- Which are the different controls in MFC ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- CAnimateCtrl, CButton, CEdit, CListBox, CComboBox, CRichEditCtrl, CStatic, TreeCtrl, ToolTipCtrl, IPAddressCtrl, TabCtrl,CDa teTimeCtrl, HeaderCtrl, ListCtrl, MonthCalCtrl, OleCtrl, ProgressCtrl, ScrollBar, SliderCtrl, StatusBarCtrl, TollBarCtrl etc.,&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the use of OnInitDialog ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- This message is sent to the dialog box during the Create, CreateIndirect, or DoModal calls, which occur immediately before the dialog box is displayed. This can be used to intialize the dialog controls or show/hide the controls etc.,&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the functioning of UpdateData() funciton ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- This is to initialize data in a dialog box, or to retrieve and validate dialog data.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The framework automatically calls UpdateData with bSaveAndValidate set to FALSE when a modal dialog box is created in the default implementation of CDialog::OnInitDialog. The call occurs before the dialog box is visible. The default implementation of CDialog::OnOK calls this member function with bSaveAndValidate set to TRUE to retrieve the data, and if successful, will close the dialog box. If the Cancel button is clicked in the dialog box, the dialog box is closed without the data being retrieved.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- How to update all the views whenever document got updated ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- call UpdateAllViews()- which updates all views associated with the document by calling OnUpdate() function of all the views.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- How to handle RTTI in MFC ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Run-Time Type Information is a mechanism that allows the type of an object to be determined during the program execution. 3 main elements to RTTI in MFC are&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;1. Dynamic_cast operator Used for conversion of polymorphic types.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;2. typeid - used for identifying the exact type of an object &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;3. type_info classused to hold the type information returned by typeid.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is serialization ?which function is responsible for serializing data ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Searialization is the process of streaming the object data to or from a persistent storage medium. It's useful in Doc-View Architecture. CObject :: Serialize() function is used to do serialization.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- what is the use of Mutex and critical section ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Mutex as the name suggest allows a mutullay exclusive access to a shared resource among the threads. Critical section is a piece of code that can be executed safely to be accessed by two or more threads. Criticalsection provides synchronization means for one process only, while mutexes allow data synchronization across processes. Means two or more threads can share the common resources among more than one &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: 15px; line-height: 17px; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;application or process boundaries in mutex.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>MFC Interview Questions &amp; Answers - 0</title><link>http://mfcmisc.blogspot.com/2009/04/mfc-interview-questions-answers-0.html</link><category>MFC</category><category>Socket</category><category>UNICODE</category><category>Win32 API</category><author>noreply@blogger.com (Anil)</author><pubDate>Fri, 3 Apr 2009 05:44:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-3806632710524398772</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is socket?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- A "socket" is an endpoint of communication: an object through which your application communicates with other Windows Sockets applications across a network.The two MFC Windows Sockets programming models are supported by the following classes: CAsyncSocket and CSocket&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the difference between Synchronous sockets and asynchronous sockets?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Consider a server application that is listening on a specific port to get data from clients. In synchronous receiving, while the server is waiting to receive data from a client, if the stream is empty the main thread will block until the request for data is satisfied. Hence, the server cannot do anything else until it receives data from the client. If another client attempts to connect to the server at that time, the server cannot process that request because it is blocked on the first client. This behavior is not acceptable for a real-world application where we need to support multiple clients at the same time. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;In asynchronous communication, while the server is listening or receiving data from a client, it can still process connection requests from other clients as well as receive data from those clients. When a server is receiving asynchronously, a separate thread (at the OS level) listens on the socket and will invoke a callback function when a socket event occurs. This callback function in turn will respond and process that socket event.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- Have you ever used win32 APIs ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- MFC is a wrapper around win32 API, It provides classes which uses the win32 API, Some of the API's we usually work with are : GetDlgItemInt,GetDlgItemText,GetWindowTextA,Messag eBoxA,CreateFile,CreateMutex,CreateEvent,WaitForSi ngleObject,CreateWindow,ShowWindow etc.,&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the difference between ANSI Code and UNICODE ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- ANSI code represents 8bytes data where UNICODE represents 16bytes data for supporting universal languages. One major draw back to ASCII was you could only have 256 different characters. However, languages such as Japanese and Arabic have thousands of characters. Thus ASCII would not work in these situations. The result was Unicode which allowed for up to 65,536 different character&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is the difference between regular dlls and extended dlls?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Regular dlls wraps only the c/c++ functions. Where extention dlls include c++ interfaces where we can create the objects of it and use in our classes. Extended dlls support object oriented concepts.Regural dlls uses mfc internally and exported functions can be used by any mfc or non-mfc applications.Extention dlls implements reusable classes derived from mfc library,built using dll version of mfc.Only mfc executables(applications/dll-shared version of mfc) can use extention dlls.extention dlls used for passing mfc derived objects b/w applications and dlls. Regulardlls linked both statically and dynamically but extended dlls links dynamically.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- What is a message map, and what is the advantage of a message map over virtual function ?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- MessageMap is a logical table that maps the windows messages to the member functions of the class. We use message maps over virtual function because of lots of overhead. If every windows message had a virtual function associated with it , there would be several hundred bytes per window class of vtable. Message maps means we only pay for the messages we use.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- Given two processes, how can they share memory?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Processes and thread are very similar but they differ in the way they share their resources. Processes are independent and have its own address space. If two independent processes want to communicate they do this by using the following techniques 1.Message Passing 2.Sockets 3. named pipes&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Or&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Use memory-mapped files to share data memory between processes&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- How to restrict only one instance of a class object to be created?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- Create a Named Mutex.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;HANDLE hMutex=CreateMutex(TRUE,_T(“NamedMutex”))&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;And check the Mutex existence for each of your instance launch and dont allow it to launch if it exists.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:- How do I dynamically change the mainframe menu?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ans:- CMenu newMenu;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;newMenu.LoadMenu (IDR_MENU1);&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;AfxGetMainWnd()-&gt;SetMenu( &amp;amp;newMenu );&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;AfxGetMainWnd()-&gt;DrawMenuBar();&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;newMenu.Detach ()&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>C++ Interview Questions &amp; Answers</title><link>http://mfcmisc.blogspot.com/2009/04/c-interview-questions-answers.html</link><category>C++</category><category>copy Constructor</category><category>Virtual Constructor</category><category>Virtual Destructor</category><author>noreply@blogger.com (Anil)</author><pubDate>Fri, 3 Apr 2009 05:38:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-6181195335138638245</guid><description>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: There is nothing like Virtual Constructor. The Constructor can’t be virtual as the constructor&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;is a code which is responsible for creating an instance of a class and it can’t be delegated to&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;any other object by virtual keyword means.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: What is constructor or ctor?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: Constructor creates an object and initializes it. It also creates vtable for virtual functions. It is&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;different from other methods in a class.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: What about Virtual Destructor?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;depending on the type of object caller is calling to, proper destructor will be called.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: What is the difference between a copy constructor and an overloaded assignment operator?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: A copy constructor constructs a new object by using the content of the argument object. An&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;overloaded assignment operator assigns the contents of an existing object to another existing&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;object of the same class.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: Can a constructor throws an exception? How to handle the error when the constructor fails?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A:The constructor never throws an error.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: What is default constructor?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: Constructor with no arguments or all the arguments has default values.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: What is copy constructor?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: Constructor which initializes the it's object member variables ( by shallow copying) with another object of the same class. If you don't implement one in your class then compiler implements one for you. for example:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;(a) Boo Obj1(10); // calling Boo constructor&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;(b) Boo Obj2(Obj1); // calling boo copy constructor&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;(c) Boo Obj2 = Obj1;// calling boo copy constructor&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: When are copy constructors called?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: Copy constructors are called in following cases:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;(a) when a function returns an object of that&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;class by value&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;(b) when the object of that class is passed by&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;value as an argument to a function&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;(c) when you construct an object based on another&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;object of the same class&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;(d) When compiler generates a temporary object&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: Can a copy constructor accept an object of the same class as parameter, instead of reference&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;of the object?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: No. It is specified in the definition of the copy constructor itself. It should generate an error if&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;a programmer specifies a copy constructor with a first argument that is an object and not a&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;reference.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: What is conversion constructor?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: constructor with a single argument makes that constructor as conversion ctor and it can be&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;used for type conversion.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;for example:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;class Boo&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Boo( int i );&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;};&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Boo BooObject = 10 ; // assigning int 10 Boo object&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q:What is conversion operator??&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A:class can have a public method for specific data type conversions.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;for example:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;class Boo&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;double value;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Boo(int i )&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;operator double()&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;return value;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;};&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Boo BooObject;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;double i = BooObject; // assigning object to variable i of type double.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;now conversion operator gets called to assign the value.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: How can I handle a constructor that fails?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: throw an exception. Constructors don't have a return type, so it's not possible to use return&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;codes. The best way to signal constructor failure is therefore to throw an exception.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Q: How can I handle a destructor that fails?&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;A: Write a message to a log-_le. But do not throw an exception. The C++ rule is that you must&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;never throw an exception from a destructor that is being called during the "stack unwinding"&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;process of another exception. For example, if someone says throw Foo(), the stack will be&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;popped. This is called stack unwinding. During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a }&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;catch (Bare) { handler? There is no good answer:either choice loses information. So the C++ language guarantees that it will call terminate() at this point, and&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;terminate() kills the process. Bang you're dead.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Encapsulation</title><link>http://mfcmisc.blogspot.com/2009/04/encapsulation.html</link><category>Encapsulation</category><author>noreply@blogger.com (Anil)</author><pubDate>Fri, 3 Apr 2009 05:34:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-5269150626154875899</guid><description>&lt;span class="Apple-style-span"   style="color: rgb(51, 51, 51);   font-family:'Lucida Grande';font-size:13px;"&gt;&lt;h3  style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;  color: rgb(119, 119, 119); margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size:1.2em;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Encapsulation&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Think of encapsulation as a black box; data is sent to a method, a lot of work goes on using the data, of which you don't know or care about. An output is returned to the caller. That is the process of encapsulation, or &lt;/span&gt;&lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;information hiding&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. Let's take a look at the following class:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="dp-highlighter nogutter" style="width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; color: black; background-color: rgb(251, 237, 187); "&gt;&lt;div class="bar" style="padding-left: 0px; "&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="margin-top: 0px; margin-right: 0px; margin-bottom: 1px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(43, 145, 175); list-style-type: none; margin-left: 0px; "&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; MultiLineString  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; CollectionBase&lt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&gt; _lines = &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; _allowEmptyLines = &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; _lock = &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;();  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; AllowEmptyLines  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; { &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; _allowEmptyLines; }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;set&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; { _allowEmptyLines = value; }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; LineCount  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; { &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; _lines.Count; }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; index]  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; { &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; _lines[index]; }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; MultiLineString(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; text) : &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(text, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;) { }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; MultiLineString(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; text, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; allowEmptyLines)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    _allowEmptyLines = allowEmptyLines;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    _lines = &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; CollectionBase&lt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&gt;();  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (!allowEmptyLines)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[] lines = text.Split(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="string"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;'\n'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;);  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;foreach&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; line &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;in&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; lines)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;      {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (line != &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.Add(line);  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (line == &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="string"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;'\r'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &amp;amp;&amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.AllowEmptyLines)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.Add(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.Empty);  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;      }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; MultiLineString(StringBuilder builder) : &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(builder, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;) { }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; MultiLineString(  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    StringBuilder builder,   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; allowEmptyLines) : &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(builder.ToString(), allowEmptyLines) { }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; AddLine(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; line)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.AllowEmptyLines &amp;amp;&amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.IsNullOrEmpty(line))  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; ArgumentNullException(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="string"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"line"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;);  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;lock&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (_lock)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;      _lines.Add(&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.TrimLine(line));  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; RemoveLine(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; index)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;lock&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (_lock)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;      _lines.RemoveAt(index);  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;override&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; ToString()  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; output = &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.Empty;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;foreach&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; line &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;in&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; lines)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;      output += line + &lt;/span&gt;&lt;/span&gt;&lt;span class="string"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;"\n"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; output;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; TrimLine(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; line)  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; line.Trim(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;char&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[] { &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="string"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;' '&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="string"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;'\t'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="string"  style=" ;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;'\r'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; });  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=""  style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border- color:initial;"&gt;&lt;span style=" ;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;From this class, we see a class that works with multi-line text, ensuring that the new line text is separated by line and retrieved by an index value. The &lt;/span&gt;&lt;/span&gt;&lt;code  style=" color: rgb(153, 0, 0); font-size:1.2em;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;constructor&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; takes a&lt;/span&gt;&lt;/span&gt;&lt;code  style=" color: rgb(153, 0, 0); font-size:1.2em;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; and parses the initial text. It also allows the adding and removing of lines. However, notice that the base object that stores the lines, the &lt;/span&gt;&lt;/span&gt;&lt;code  style=" color: rgb(153, 0, 0); font-size:1.2em;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;CollectionBase&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; object, is never exposed. Only certain object properties are exposed, but the list isn't directly exposed. This is information hiding, in that we don't need to expose the source object for subscriber to use it, but the subscriber can only use the exposed methods/properties to interact with it.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Why is encapsulation important? Using the above example, it would be really easy to change the underlying source to use a database, XML file, text file, or another data store, without breaking any code that the developer may have created. If the class exposed the list directly, any code that used the list would have to change, replacing it with database code. That makes using this class much harder to maintain and more likely that someone would stay away from using the class. But with the implementation above, nothing is known about the source and so switching the underlying data source is much easier.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This concept is prevalent throughout the .NET framework and any object-oriented development project, as it is important to hide certain information to the consumer of an object, because it aids in maintenance, development, and general use of the object.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Polymorphism</title><link>http://mfcmisc.blogspot.com/2009/04/polymorphism.html</link><category>Polymorphism</category><author>noreply@blogger.com (Anil)</author><pubDate>Fri, 3 Apr 2009 05:22:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-8933208440320377766</guid><description>&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Grande'; font-size: 13px; "&gt;&lt;h3 style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.2em; color: rgb(119, 119, 119); margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Polymorphism&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Polymorphism is a simple concept that you understand right now, as it is prevalent through life. You are a person, which person is a base type and you are a more specific representation of that type. There are many people that &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;inherit&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; that type, of which you are a &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;concrete&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; implementation of that type: you have your own beliefs, attributes, and qualities that go beyond just a general person. For instance, we all have a blood type, shoe size, arm length, and many other properties. But we each add our own implementation to the &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;person&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; interface.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;You drive an automobile, which this type has properties like wheel size, engine size, gas tank size, and other properties. The automobile you drive is a concrete implementation of the &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;automobile interface&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;. It has additional features, like sliding doors, logo type, cd changer slot count, moon roof lever location, or other various properties that are specific to the make/model of the car. In addition, automobile may have certain behaviors like open/close door, open trunk, turn wheel, and other behaviors that would be specific to an automobile.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;In OO programming, using the automobile example, Automobile would be the base class, and each automobile manufacturer would have its own implementation. For instance, Honda has V-Tec technology, which is in its own implementation. Volvo uses &lt;/span&gt;&lt;a class="iAs" classname="iAs" href="http://dotnetslackers.com/articles/csharp/PolymorphismEncapsulation.aspx#" target="_blank" itxtdid="8664186" style="font-weight: normal !important; font-size: 100% !important; border-bottom-color: rgb(0, 100, 0) !important; border-bottom-width: 0.075em !important; border-bottom-style: solid !important; padding-bottom: 1px !important; background-color: transparent !important; text-decoration: none; color: rgb(0, 173, 239); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;diesel&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; engines, which is the TDI technology. More importantly, you may add an added level of detail between automobile and the make/model implementation, such as Car, Truck, or Suv supertypes, to provide more relevant information.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Let's take a look at the automobile scenario. Here is an example automobile class:&lt;/span&gt;&lt;/p&gt;&lt;div class="dp-highlighter nogutter" style="width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-size: 0.9em; color: black; background-color: rgb(251, 237, 187); "&gt;&lt;div class="bar" style="padding-left: 0px; "&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="margin-top: 0px; margin-right: 0px; margin-bottom: 1px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(43, 145, 175); list-style-type: none; margin-left: 0px; "&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;abstract&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; Automobile  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="comment" style="color: green; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;//Properties&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; DoorCount { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; EngineType { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;float&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; Height { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;float&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; GasTankSize { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;float&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; WheelBase { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;float&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; WheelSize { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="comment" style="color: green; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;//Abstract Properties&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;abstract&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; BodyType { &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;; }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="comment" style="color: green; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;//Methods&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;float&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; CalculateFuelEfficiency(&lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; lastMileage);  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; class is the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;interface&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, in that it defines an &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;interface&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; that classes will derive from. You can't directly instantiate it through &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;new Automobile()&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; because it's not an implementation; however, you can cast derived types to the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; type. In this sense, it defines a common &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;interface&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; across many derived implementations.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;It's important to note the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;BodyType&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; property. This property is declared &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;abstract&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, meaning that any derived implementation must override it and return some relevant string (we will see more of this with the next class definitions). This is similar to the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Template&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; Method pattern in that it exposes properties/methods that derived classes must override, but which &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; doesn't need to know anything about. &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; wants the derived class to return something relevant to it, but doesn't care what.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Now, from the example above, let's say we want a higher level of abstraction, in that there are varying types of &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;cars&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; and we want to target that. It is possible for classes to inherit from &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, but to also be an &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;interface&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; in that it can't be directly instantiated, but any class can inherit additional properties/methods from it. Below are two such class definitions, for &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; and &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Suv&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div class="dp-highlighter nogutter" style="width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-size: 0.9em; color: black; background-color: rgb(251, 237, 187); "&gt;&lt;div class="bar" style="padding-left: 0px; "&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="margin-top: 0px; margin-right: 0px; margin-bottom: 1px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(43, 145, 175); list-style-type: none; margin-left: 0px; "&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;abstract&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; Car : Automobile  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="comment" style="color: green; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;//Properties&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; HasSpoiler { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; IsHatchback { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="comment" style="color: green; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;//Overridden Properties (abstract)&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;override&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; BodyType { &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; { &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="string" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;"Car"&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;; } }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="comment" style="color: green; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;//Abstract properties&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;abstract&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; IsFast { &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;; }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;abstract&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; Suv : Automobile  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; CanOffroad { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; TowingCapacity { .. }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;override&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; BodyType { &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; { &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="string" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;"SUV"&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;; } }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Notice the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;BodyType&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; method is overridden to return a &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;string&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; that represents the type of body that's appropriate to the &lt;/span&gt;&lt;a href="http://www.martinfowler.com/eaaCatalog/layerSupertype.html" rel="nofollow" style="text-decoration: none; color: rgb(0, 173, 239); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;supertype&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;. Also notice that &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; and &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Suv&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; also expose their own properties/methods, even abstractly in terms of the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car.IsFast&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; property. Lastly, let's create an implementation of the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; class:&lt;/span&gt;&lt;/p&gt;&lt;div class="dp-highlighter nogutter" style="width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; font-size: 0.9em; color: black; background-color: rgb(251, 237, 187); "&gt;&lt;div class="bar" style="padding-left: 0px; "&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="margin-top: 0px; margin-right: 0px; margin-bottom: 1px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(43, 145, 175); list-style-type: none; margin-left: 0px; "&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; SubaruWrx : Car  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;override&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; IsFast  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  {  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;    &lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; { &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="keyword" style="color: blue; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;; }  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  }  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="padding-left: 10px; line-height: 14px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "&gt;&lt;span style="color: black; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;SubaruWrx&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; class can use any of the properties defined in &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; and &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;. It has &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;DoorCount&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;EngineType&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, etc. properties that are available, because it inherits from &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, which &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; inherits from &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;. You can cast &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;SubaruWrx&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; to &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; or to &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, because it inherits from these base classes, and adds its own properties/methods. However, say you cast &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;SubaruWrx&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; to &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;; none of the properties/methods defined in &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;SubaruWrx&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; or &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Car&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; will be available, because all this object knows is that it's of type &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Automobile&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;. To gain access to those properties/methods, you must upcast to the appropriate type.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;There are several ways that polymorphism can take place. The first is through class inheritance, which you see above. Class inheritance exposes the interface of the base class to all of the derived classes. Another option is &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;interface&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; inheritance. The &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;interface&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; declares a contract that the class must follow to implement the interface. In addition to class inheritance, an object can inherit from one or more interfaces, which adds properties/methods to the body of the class that it must provide implementation for. This is another common option that can be used in .NET development. Some languages offer the ability to inherit from multiple base classes; however, .NET is not one of those languages.&lt;/span&gt;&lt;/p&gt;&lt;h3 style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.2em; color: rgb(119, 119, 119); margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Examples of Polymorphism&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;There are many examples of Polymorphism in the .NET framework. One of them is the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Membership&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; provider. When you call &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Membership.GetUser&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; or any other method, it calls the default provider, which is defined as a &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;MembershipProvider&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; class. Any derivatives (&lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;SqlMembershipProvider&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; or other custom providers) expose the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;MembershipProvider interface&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; to create a concrete implementation. You can easily switch the underlying data store without having to change any code for the &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Membership&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; object.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;When you work with a typed &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;dataset&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, the base objects for the tables/rows are inherited from &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;DataTable&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; and &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;DataRow&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;. These objects can be downcast to this base type. When downcast to this type, only the properties/methods defined in &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;DataTable/DataRow&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; can be used, eliminating the strong-typing that comes from a typed &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;dataset&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;GridView&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; and &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;DetailsView&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; web controls allow you to create custom fields, by creating a class that inherits from &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;DataControlField&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;. Because of this, you do not have to create your own custom &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;GridView/DetailsView&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; classes to expose new field types; you simply create a new field that inherits from &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;DataControlField&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, and create a custom implementation by overriding the base class's &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;ExtractValuesFromCell&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; and &lt;/span&gt;&lt;code style="font-size: 1.2em; color: rgb(153, 0, 0); "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;InitializeCell&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; methods.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Type Char Expected Input - Format of output</title><link>http://mfcmisc.blogspot.com/2009/03/type-char-expected-input-format-of.html</link><author>noreply@blogger.com (Anil)</author><pubDate>Tue, 3 Mar 2009 20:27:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-4027421546769710509</guid><description>&lt;span class="Apple-style-span" style="font-family: Verdana; line-height: 17px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;d Integer signed decimal integer&lt;br /&gt;i Integer signed decimal integer&lt;br /&gt;o Integer unsigned octal integer&lt;br /&gt;u Integer unsigned decimal integer&lt;br /&gt;x Integer unsigned hexadecimal int (with a, b, c, d, e, f)&lt;br /&gt;X Integer unsigned hexadecimal int (with A, B, C, D, E, F)&lt;br /&gt;f Floating point signed value of the form [-]dddd.dddd.&lt;br /&gt;&lt;br /&gt;e Floating point signed value of the form [-]d.dddd or e&lt;br /&gt;[+/-]ddd&lt;br /&gt;g Floating point signed value in either e or f form, based on given value and precision. Trailing zeros and the decimal point are printed if necessary.&lt;br /&gt;E Floating point Same as e; with E for exponent.&lt;br /&gt;G Floating point Same as g; with E for exponent if e format used&lt;br /&gt;&lt;br /&gt;Characters&lt;br /&gt;c Character Single character&lt;br /&gt;s String pointer Prints characters until a null-terminator is pressed or precision is reached&lt;br /&gt;% None Prints the % character&lt;br /&gt;&lt;br /&gt;Pointers&lt;br /&gt;n Pointer to int Stores (in the location pointed to by the input argument) a count of the chars written so far.&lt;br /&gt;p Pointer Prints the input argument as a pointer; format depends on which memory model was used. It will be either XXXX:YYYY or YYYY (offset only).&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Arrays &amp; Pointers</title><link>http://mfcmisc.blogspot.com/2009/03/arrays-pointers.html</link><category>Array</category><category>Pointer</category><author>noreply@blogger.com (Anil)</author><pubDate>Sun, 1 Mar 2009 22:12:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-2529665709501575282</guid><description>&lt;h2 id="ary"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Arrays&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx384" name="idx384"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx385" name="idx385"&gt;&lt;/a&gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;An &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;array&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;is a collection of objects of the same data type, allocated contiguously in memory. Individual objects in an array, called &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;elements&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, are accessed by their position in the array. The subscripting operator (&lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;[]&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;) provides the mechanics for creating an index to array elements. This form of access is called &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;indexing&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; or &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;subscripting&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. An array facilitates the coding of repetitive tasks by allowing the statements executed on each element to be put into a loop that iterates through each element in the array.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;h2 id="ptrdec"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Pointers&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx375" name="idx375"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx376" name="idx376"&gt;&lt;/a&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pointer&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;type variable holds the address of a data object or a function. &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A pointer can refer to an object of any one data type; it cannot refer to a bit field or a reference.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Some common uses for pointers are: &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;To access dynamic data structures such as linked lists, trees, and queues.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;To access elements of an array or members of a structure&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; or C++ class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;To access an array of characters as a string.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;To pass the address of a variable to a function. &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(In C++, you can also use a reference to do this.)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; By referencing a variable through its address, a function can change the contents of that variable.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Note that the placement of the type qualifiers &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;volatile&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; and &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;const&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; affects the semantics of a pointer declaration. If either of the qualifiers appears before the &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, the declarator describes a pointer to a type-qualified object. If either of the qualifiers appears between the &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; and the identifier, the declarator describes a type-qualifed pointer.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The following table provides examples of pointer declarations.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a name="wq108"&gt;&lt;/a&gt; &lt;/span&gt;&lt;/span&gt;&lt;table id="wq108" summary="" border="1" frame="border" rules="all" width="100%"&gt; &lt;caption&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Table 1. Pointer declarations&lt;/span&gt;&lt;/span&gt;&lt;/caption&gt; &lt;thead valign="bottom"&gt; &lt;tr valign="bottom"&gt; &lt;th id="wq109" align="left"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Declaration&lt;/span&gt;&lt;/span&gt;&lt;/th&gt; &lt;th id="wq110" align="left"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Description&lt;/span&gt;&lt;/span&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody valign="top"&gt; &lt;tr&gt; &lt;td headers="wq109"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;long *pcoat;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq110"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pcoat&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a pointer to an object having type &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;long&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td headers="wq109"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;extern short * const pvolt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq110"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pvolt&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a constant pointer to an object having type &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;short&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td headers="wq109"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;extern int volatile *pnut;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq110"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pnut&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a pointer to an &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; object having the &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;volatile&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; qualifier&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td headers="wq109"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;float * volatile psoup;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq110"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;psoup&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;volatile&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; pointer to an object having type &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;float&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td headers="wq109"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;enum bird *pfowl;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq110"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pfowl&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a pointer to an enumeration object of type &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bird&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td headers="wq109"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;char (*pvish)(void);&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq110"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pvish&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a pointer to a function that takes no parameters and returns a &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;char&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Difference:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" font-style: italic; white-space: pre; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style=" font-style: italic; white-space: pre; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&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-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Arrays &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: normal; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;automatically allocate space which is fixed in size and location; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pointers &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;are dynamic.&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" font-style: italic; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style=" font-style: italic; white-space: pre; "&gt;&lt;span class="Apple-style-span" style="font-style: normal; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" font-style: italic; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&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-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Arrays &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: normal; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;are&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: normal; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; refered directly to the elements. But in &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pointers &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;we refers to address of the elements &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;span class="Apple-style-span" style="  font-style: italic; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;but not elements . indirect calling of the elements.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="  white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&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-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;They're related but not totally comparable. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A pointer is an address in memory where a variable is located.&lt;br /&gt;&lt;br /&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-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;An array is a conceptual data representation consisting of a list of more than one item of a particular scalar type (int, float, char, structure, etc.) where each element is accessed by its index. The index can be thought of as a counter or enumerator telling you how many elements you have to skip over to get to the one you're interested in. Here's where addresses come in ... the location of a particular element in memory is offset from the so-called &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;base address&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (i.e. the address of the starting element) by the value&lt;br /&gt;&lt;br /&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-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(sizeof(one element) * index #)&lt;br /&gt;&lt;br /&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-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The C compiler is smart enough to take the sizeof() into account when you do pointer arithmetic, so you can find the address of the i-th element as (address of base) + i, rather than having to do the multiplication explicitly.&lt;br /&gt;&lt;br /&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-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The idea of element address as offset also accounts for C's use of zero-relative array definitions. Since the first element is offset by 0 positions from the first element its index in C is 0, not 1. The second (ordinal) element is offset from the first by 1 position so its index is 1, and so on.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>Member access</title><link>http://mfcmisc.blogspot.com/2009/02/member-access.html</link><category>Member access</category><author>noreply@blogger.com (Anil)</author><pubDate>Thu, 26 Feb 2009 01:37:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-7917013925165516364</guid><description>&lt;p&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Member access&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;determines if a class member is accessible in an expression or declaration. Suppose &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a member of class &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. Class member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; can be declared to have one of the following levels of accessibility:&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx1068" name="idx1068"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;: &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; can be used anywhere without the access restrictions defined by private or protected.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;: &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; can be used only by the members and friends of class &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;protected&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;: &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; can be used only by the members and friends of class &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, and the members and friends of classes derived from class &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Members of classes declared with the keyword &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; are private by default. Members of classes declared with the keyword &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;struct&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; or &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;union&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; are public by default.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;To control the access of a class member, you use one of the &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx1069" name="idx1069"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;access specifiers&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, or &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;protected&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; as a label in a class member list. The following example demonstrates these access specifiers: &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;struct A {&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  friend class C; private:   int a; public:   int b; protected:   int c;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;struct B : A {&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  void f() {     // a = 1;     b = 2;     c = 3;   }&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;struct C {&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  void f(A x) {     x.a = 4;     x.b = 5;     x.c = 6;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int main() {&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  A y; //  y.a = 7;   y.b = 8; //  y.c = 9;    B z; //  z.a = 10;   z.b = 11; //  z.c = 12;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The following table lists the access of data members &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::a&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::b&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, and &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::c&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; in various scopes of the above example.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a name="wq248"&gt;&lt;/a&gt; &lt;/span&gt;&lt;/span&gt;&lt;table id="wq248" summary="" border="1" frame="hsides" rules="all" width="100%"&gt; &lt;thead valign="bottom"&gt; &lt;tr&gt; &lt;th id="wq249" align="left"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Scope&lt;/span&gt;&lt;/span&gt;&lt;/th&gt; &lt;th id="wq250" align="left"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::a&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/th&gt; &lt;th id="wq251" align="left"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::b&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/th&gt; &lt;th id="wq252" align="left"&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::c&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody valign="top"&gt; &lt;tr&gt; &lt;td headers="wq249"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;B::f()&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq250"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::a&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is private.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td headers="wq251"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::b&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is public.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td headers="wq252"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Access. Class &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; inherits from &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td headers="wq249"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;C::f()&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq250"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Access. Class &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a friend of &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td headers="wq251"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::b&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is public.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td headers="wq252"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Access. Class &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a friend of &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td headers="wq249"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;object &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;y&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; in  &lt;/span&gt;&lt;/span&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;main()&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt; &lt;td headers="wq250"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;y.a&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is private.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td headers="wq251"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;y.a&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is public.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td headers="wq252"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;y.c&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is protected.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td headers="wq249"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;object &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;z&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; in &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;main()&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/td&gt; &lt;td headers="wq250"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;z.a&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is private.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td headers="wq251"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;z.a&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is public.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td headers="wq252"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;No access. Member &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;z.c&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is protected.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;An access specifier specifies the accessibility of members that follow it until the next access specifier or until the end of the class definition. You can use any number of access specifiers in any order. If you later define a class member within its class definition, its access specification must be the same as its declaration. The following example demonstrates this: &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;class A {&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    class B;   public:     class B { };&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p class="indatacontent"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The compiler will not allow the definition of class &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; because this class has already been declared as private.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A class member has the same access control regardless whether it has been defined within its class or outside its class.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Access control applies to names. In particular, if you add access control to a typedef name, it affects only the typedef name. The following example demonstrates this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;class A {&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    class B { };   public:     typedef B C;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int main() {&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  A::C x; //  A::B y;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p class="indatacontent"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The compiler will allow the declaration &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::C x&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; because the typedef name &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::C&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is public. The compiler would not allow the declaration &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::B y&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; because &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::B&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is private.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx1070" name="idx1070"&gt;&lt;/a&gt;Note that accessibility and visibility are independent. Visibility is based on the scoping rules of C++. A class member can be visible and inaccessible at the same time.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Abstract class</title><link>http://mfcmisc.blogspot.com/2009/02/abstract-class.html</link><category>abstract class</category><author>noreply@blogger.com (Anil)</author><pubDate>Thu, 26 Feb 2009 01:00:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-7460684683084834309</guid><description>&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;An &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;abstract class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a class that is designed to be specifically used as a base class. An abstract class contains at least one &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx1185" name="idx1185"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pure virtual function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. You declare a pure virtual function by using a &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx1186" name="idx1186"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pure specifier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; (&lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;= 0&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;) in the declaration of a virtual member function in the class declaration.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The following is an example of an abstract class:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;class AB {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  virtual void f() = 0;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  white-space: pre;font-family:verdana;font-size:13px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Virtual Function</title><link>http://mfcmisc.blogspot.com/2009/02/virtual-function.html</link><category>dynamic binding</category><category>static binding</category><category>virtual function</category><author>noreply@blogger.com (Anil)</author><pubDate>Wed, 25 Feb 2009 22:45:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-5244751099473450183</guid><description>&lt;span class="Apple-style-span"  style=" ;font-family:'Times New Roman';"&gt;&lt;div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A function call with the correct function definition at compile time. This is called &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;static binding&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. You can specify that the compiler match a function call with the correct function definition at run time; this is called &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;dynamic binding&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. You declare a function with the keyword virtual if you want the compiler to use dynamic binding for that specific function.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "&gt;&lt;span class="Apple-style-span" style="  white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;virtual function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a member function you may redefine for other derived classes, and can ensure that the compiler will call the redefined virtual function for an object of the corresponding derived class, even if you call that function with a pointer or reference to a base class of the object.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A class that declares or inherits a virtual function is called a &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;polymorphic class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The following example demonstrates this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;include &lt;/span&gt;&lt;/span&gt;&lt;iostream&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; using namespace std;&lt;/span&gt;&lt;/span&gt;&lt;/iostream&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;struct A {    virtual void f() { cout &lt;&lt; "Class A" &lt;&lt;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;struct B: A {    void f(int) { cout &lt;&lt; "Class B" &lt;&lt;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;struct C: B {    void f() { cout &lt;&lt; "Class C" &lt;&lt;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int main() {&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   B b; C c;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   A* pa1 = &amp;b;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   A* pa2 = &amp;c;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   pa1-&gt;f();&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   pa2-&gt;f();&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p class="indatacontent"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The following is the output of the above example:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Class A &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="xmp"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Class C&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p class="indatacontent"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The function &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;B::f&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is not virtual. It hides &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::f&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. Thus the compiler will not allow the function call &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;b.f()&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. The function &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;C::f&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is virtual; it overrides &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::f&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; even though &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A::f&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is not visible in &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;If you declare a base class destructor as virtual, a derived class destructor will override that base class destructor, even though destructors are not inherited.&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Inheritance</title><link>http://mfcmisc.blogspot.com/2009/02/inheritance.html</link><category>Inheritance</category><category>Multiple inheritance</category><author>noreply@blogger.com (Anil)</author><pubDate>Wed, 25 Feb 2009 21:59:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-7352465708331718701</guid><description>&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Inheritance &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;is a mechanism of reusing and extending existing classes without modifying them, thus producing hierarchical relationships between them.&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="italic"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Multiple inheritance&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; allows you to create a derived class that inherits properties from more than one base class. Because a derived class inherits members from all its base classes, ambiguities can result. For example, if two base classes have a member with the same name, the derived class cannot implicitly differentiate between the two members. Note that, when you are using multiple inheritance, the access to names of base classes may be ambiguous.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:verdana;font-size:13px;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;A &lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;direct base class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a base class that appears directly as a base specifier in the declaration of its derived class.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx1089" name="idx1089"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a id="idx1090" name="idx1090"&gt;&lt;/a&gt;An&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;indirect base class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;is a base class that does not appear directly in the declaration of the derived class but is available to the derived class through one of its base classes. For a given class, all base classes that are not direct base classes are indirect base classes.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Constructor &amp; Destructor</title><link>http://mfcmisc.blogspot.com/2009/02/constructor-destructor.html</link><category>Contructor</category><category>Destructor</category><category>Virtual Destructor</category><author>noreply@blogger.com (Anil)</author><pubDate>Wed, 25 Feb 2009 20:45:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-2070854358859599172.post-7723958912001510648</guid><description>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Constructor :- &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Constructor creates an object and initializes it. It also creates V-Table for virtual functions. It is different from other methods in a class.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Constructors are used to create, and can initialize, objects of their class type. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;You cannot declare a constructor as virtual or static, nor can you declare a constructor as const, volatile, or const volatile. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;You do not specify a return type for a constructor. A return statement in the body of a constructor cannot have a return value.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Virtual Constructor :-&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;It is not possible to have Virtual Constructor.The constructor can’t be virtual as the constructor is a code which is responsible for creating an instance of a class and it can’t be delegated to any other object by virtual keyword means.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Destructor :- &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&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. A destructor is called for a class object when that object passes out of scope or is explicitly deleted.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Virtual Destructor :- &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;A Virtual destructor can be virtual as it is possible as at runtime depending on the type of object caller is calling to, proper destructor will be called.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pseudo-destructor :-&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;A &lt;/span&gt;&lt;/span&gt;&lt;span class="italic"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;pseudo-destructor&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is a destructor of a nonclass type.&lt;br /&gt;&lt;/span&gt;&lt;/span&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-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The following example calls the pseudo destructor for an integer type:&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;typedef int I;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;int main() {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  I x = 10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  x.I::~I();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  x = 20;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;p&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;The call to the pseudo destructor, &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;x.I::~I()&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;, has no effect at all. Object &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; has not been destroyed; the assignment &lt;/span&gt;&lt;/span&gt;&lt;tt class="xph"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;x = 20&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; is still valid. Because pseudo destructors require the syntax for explicitly calling a destructor for a nonclass type to be valid, you can write code without having to know whether or not a destructor exists for a given type.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;MFC Information&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item></channel></rss>