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

<channel>
	<title>C++ - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/category/cpp/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/category/cpp/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Fri, 19 Aug 2022 12:34:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>C++ - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/category/cpp/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What are Virtual functions in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-are-virtual-functions-in-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-are-virtual-functions-in-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 12:34:29 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[advantages of virtual function in c++]]></category>
		<category><![CDATA[C++ virtual function]]></category>
		<category><![CDATA[C++ Virtual Functions]]></category>
		<category><![CDATA[virtual and pure virtual function in c++]]></category>
		<category><![CDATA[virtual class in c++]]></category>
		<category><![CDATA[virtual function example]]></category>
		<category><![CDATA[Virtual Function in C++]]></category>
		<category><![CDATA[what is pure virtual function in c++]]></category>
		<category><![CDATA[what is virtual function]]></category>
		<category><![CDATA[Why do we need virtual functions in C++?]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4820</guid>

					<description><![CDATA[Virtual function is a member function which is re-defined by a derived class and declared within a base class. When you refer to a derived class object using a reference or pointer to the base class, you can call a virtual function for that object and execute the derived class’s version of the function. It [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">Virtual function is a member function which is re-defined by a derived class and declared within a base class.</li>
<li style="text-align: justify;">When you refer to a derived class object using a reference or pointer to the base class, you can call a virtual function for that object and execute the derived class’s version of the function.</li>
<li style="text-align: justify;">It ensures that the correct function is called for an object, regardless of the type of reference used for function call.</li>
<li style="text-align: justify;">It is mainly used to achieve Run-time polymorphism.</li>
<li style="text-align: justify;">In base class functions are declared with a <strong>virtual. </strong>At run time the resolving of function call is done.</li>
</ul>
<h2 id="sample-code" style="text-align: justify;">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;<br/> <br/>class base {<br/>public:<br/>    virtual void print()<br/>    {<br/>        cout &lt;&lt; &quot;print base class\n&quot;;<br/>    }<br/> <br/>    void show()<br/>    {<br/>        cout &lt;&lt; &quot;show base class\n&quot;;<br/>    }<br/>};<br/> <br/>class derived : public base {<br/>public:<br/>    void print()<br/>    {<br/>        cout &lt;&lt; &quot;print derived class\n&quot;;<br/>    }<br/> <br/>    void show()<br/>    {<br/>        cout &lt;&lt; &quot;show derived class\n&quot;;<br/>    }<br/>};<br/> <br/>int main()<br/>{<br/>    base *bptr;<br/>    derived d;<br/>    bptr = &amp;d;<br/> <br/>    // Virtual function, binded at runtime<br/>    bptr-&gt;print();<br/> <br/>    // Non-virtual function, binded at compile time<br/>    bptr-&gt;show();<br/>   <br/>    return 0;<br/>}</code></pre> </div>
<h2 id="output" style="text-align: justify;">Output</h2>
<p style="text-align: justify;"><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-4821" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-function.png" alt="" width="875" height="162" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-function.png 875w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-function-300x56.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-function-768x142.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-function-390x72.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-function-820x152.png 820w" sizes="(max-width: 875px) 100vw, 875px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-are-virtual-functions-in-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is exception handling in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-exception-handling-in-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-exception-handling-in-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 12:27:33 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[advantages of exception handling in c]]></category>
		<category><![CDATA[does c++ have exception handling]]></category>
		<category><![CDATA[exception handling in c]]></category>
		<category><![CDATA[exception handling in c using class]]></category>
		<category><![CDATA[exception handling in oops]]></category>
		<category><![CDATA[trycatch throw in c]]></category>
		<category><![CDATA[types of exception handling in c]]></category>
		<category><![CDATA[what do you mean by exception handling in c++]]></category>
		<category><![CDATA[what is custom exception handling in c++]]></category>
		<category><![CDATA[what is exception handling in c++]]></category>
		<category><![CDATA[what is exception handling in c++ with example]]></category>
		<category><![CDATA[what is exception handling in computer architecture]]></category>
		<category><![CDATA[what is exception handling mechanism in c++]]></category>
		<category><![CDATA[what is exception in c]]></category>
		<category><![CDATA[what is the advantage of exception handling in c++]]></category>
		<category><![CDATA[what is the difference between the exception handling in c and c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4817</guid>

					<description><![CDATA[In C++ exception handling is a process to handle runtime errors. If we perform exception handling, so the normal flow of the application can be maintained even after runtime errors. At run time exception is an event or object which is thrown in C++ and all exceptions are derived from std::exception class. It prints exception [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In C++ exception handling is a process to handle runtime errors.</li>
<li style="text-align: justify;">If we perform exception handling, so the normal flow of the application can be maintained even after runtime errors.</li>
<li style="text-align: justify;">At run time exception is an event or object which is thrown in C++ and all exceptions are derived from std::exception class.</li>
<li style="text-align: justify;">It prints exception message and terminates the program, if we don&#8217;t handle the exception.</li>
<li style="text-align: justify;">In C++ exception handling consists of three keywords, they are try, throw, catch</li>
<li style="text-align: justify;">In exception handling try keyword allows you to define a block of code to be tested for errors when it is being executed.</li>
<li style="text-align: justify;">In exception handling throw keyword throws an exception when a problem is detected, which lets us create a custom error.</li>
<li style="text-align: justify;">In exception handling catch keyword allows you to define a block of code to be executed, if an error occurs in the try block.</li>
</ul>
<h2 id="syntax">Syntax</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">             try {<br/>  // Block of code to try<br/>  throw exception; // Throw an exception when a problem arise<br/>}<br/>catch () {<br/>  // Block of code to handle errors<br/>} </code></pre> </div>
<h2 id="sample-code">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">try {<br/>  int age = 15;<br/>  if (age &gt;= 18) {<br/>    cout &lt;&lt; &quot;Access granted - you are old enough.&quot;;<br/>  } else {<br/>    throw (age);<br/>  }<br/>}<br/>catch (int myNum) {<br/>  cout &lt;&lt; &quot;Access denied - You must be at least 18 years old.\n&quot;;<br/>  cout &lt;&lt; &quot;Age is: &quot; &lt;&lt; myNum;<br/>}</code></pre> </div>
<h2 id="output">Output</h2>
<p><img decoding="async" class="alignnone size-full wp-image-4818" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/exception-handling.png" alt="" width="1296" height="439" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/exception-handling.png 1296w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/exception-handling-300x102.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/exception-handling-1024x347.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/exception-handling-768x260.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/exception-handling-390x132.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/exception-handling-820x278.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/exception-handling-1180x400.png 1180w" sizes="(max-width: 1296px) 100vw, 1296px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-exception-handling-in-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is namespace in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-namespace-in-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-namespace-in-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 12:20:28 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[advantages of namespace in c++]]></category>
		<category><![CDATA[namespace example]]></category>
		<category><![CDATA[namespace in c++]]></category>
		<category><![CDATA[what is namespace in c plus plus]]></category>
		<category><![CDATA[what is namespace in c++]]></category>
		<category><![CDATA[what is namespace in c++ with example]]></category>
		<category><![CDATA[what is namespace in cpp]]></category>
		<category><![CDATA[what is namespace std in c++]]></category>
		<category><![CDATA[what is std in c++]]></category>
		<category><![CDATA[what is the purpose of namespace in c++]]></category>
		<category><![CDATA[what is the use of namespace in c++]]></category>
		<category><![CDATA[what is using namespace std in c plus plus]]></category>
		<category><![CDATA[what is using namespace std in c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4814</guid>

					<description><![CDATA[In C++ namespace is a logical division of the code which is designed to stop the naming conflict. In C++ namespace defines the scope where the identifiers such as variables, class, functions are declared. The main purpose of using namespace is to remove the ambiguity in C++. If different task occurs with the same name [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In C++ namespace is a logical division of the code which is designed to stop the naming conflict.</li>
<li style="text-align: justify;">In C++ namespace defines the scope where the identifiers such as variables, class, functions are declared.</li>
<li style="text-align: justify;">The main purpose of using namespace is to remove the ambiguity in C++. If different task occurs with the same name their ambiguity occurs.</li>
<li style="text-align: justify;">In different namespaces functions are declared, for example if there are two functions exist with the same name such as add (), In order to prevent this ambiguity, the namespace is used.</li>
<li style="text-align: justify;">C++ language consists of a standard namespace which contains inbuilt classes and functions.</li>
<li style="text-align: justify;">In our program by using the statement &#8220;using namespace std;&#8221; includes the namespace &#8220;std&#8221;.</li>
</ul>
<h2 id="syntax">Syntax</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">namespace namespace_name  <br/>{  <br/>     //body of namespace;  <br/>}  </code></pre> </div>
<h2 id="syntax-of-accessing-the-namespace-variable">Syntax of accessing the namespace variable</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">namespace_name::member_name; </code></pre> </div>
<h2 id="sample-code">Sample code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code"> using namespace std;  <br/>namespace addition  <br/>{  <br/>    int a=5;  <br/>    int b=5;  <br/>    int add()  <br/>    {  <br/>        return(a+b);  <br/>    }  <br/>}  <br/>  <br/>int main() {  <br/>int result;  <br/>result=addition::add();  <br/>cout&lt;&lt;result;  <br/>return 0;  <br/>      }  </code></pre> </div>
<h2 id="output">Output</h2>
<p><img decoding="async" class="alignnone size-full wp-image-4815" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/namespace-1.png" alt="" width="1396" height="117" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/namespace-1.png 1396w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/namespace-1-300x25.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/namespace-1-1024x86.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/namespace-1-768x64.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/namespace-1-390x33.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/namespace-1-820x69.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/namespace-1-1180x99.png 1180w" sizes="(max-width: 1396px) 100vw, 1396px" /></p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-namespace-in-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Virtual Inheritance ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-virtual-inheritance/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-virtual-inheritance/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 12:11:08 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[how virtual inheritance works in c++]]></category>
		<category><![CDATA[virtual base class]]></category>
		<category><![CDATA[virtual function in multiple inheritance c++]]></category>
		<category><![CDATA[virtual inheritance c++]]></category>
		<category><![CDATA[virtual inheritance in c++]]></category>
		<category><![CDATA[what is virtual base class in inheritance]]></category>
		<category><![CDATA[What is virtual inheritance]]></category>
		<category><![CDATA[what is virtual inheritance in c++]]></category>
		<category><![CDATA[what is virtual inheritance mcq]]></category>
		<category><![CDATA[when do we make a class virtual in c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4810</guid>

					<description><![CDATA[During multiple inheritance Virtual Inheritance is used to remove the ambiguity of base class, when a derived class inherits the same base class via other classes in C++. For example, we consider four classes A, B, C, and D. If an object of type D tries to access members of A, ambiguity arises as to which [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">During multiple inheritance Virtual Inheritance is used to remove the ambiguity of base class, when a derived class inherits the same base class via other classes in C++.</li>
</ul>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4811 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence.png" alt="" width="985" height="1105" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence.png 985w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-267x300.png 267w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-913x1024.png 913w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-768x862.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-390x438.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-820x920.png 820w" sizes="(max-width: 985px) 100vw, 985px" /></p>
<ul style="text-align: justify;">
<li>For example, we consider four classes A, B, C, and D.</li>
<li>If an object of type D tries to access members of A, ambiguity arises as to which class it should resolve.</li>
<li>If it is class D that C inherited or it is class D that B inherited as a result, compiler throws an error.</li>
<li>We declare that B and C inherit A virtually, to remove this ambiguity.</li>
<li>It ensures that an object of type D will contain only set of member variables from A.</li>
</ul>
<h2 id="sample-code" style="text-align: justify;">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;<br/> <br/>class A {<br/>public:<br/>    int x = 2;<br/>};<br/> <br/>class B: public virtual A {<br/>};<br/> <br/>class C: public virtual A {<br/>};<br/> <br/>class D: public B, public C {<br/>};<br/> <br/>int main() {<br/>    D d = D();<br/>    cout &lt;&lt; &quot;x : &quot; &lt;&lt; d.x &lt;&lt; endl;<br/>}</code></pre> </div>
<h2 id="output" style="text-align: justify;">Output</h2>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4812" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-output.png" alt="" width="1273" height="152" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-output.png 1273w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-output-300x36.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-output-1024x122.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-output-768x92.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-output-390x47.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-output-820x98.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-inheritence-output-1180x141.png 1180w" sizes="(max-width: 1273px) 100vw, 1273px" /></p>
<p style="text-align: justify;">
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-virtual-inheritance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Template in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-template-in-c/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-template-in-c/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 11:54:35 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[advantages of templates in c++]]></category>
		<category><![CDATA[class templates in c++]]></category>
		<category><![CDATA[function template in c++ program]]></category>
		<category><![CDATA[function templates in c++]]></category>
		<category><![CDATA[template in c++]]></category>
		<category><![CDATA[template parameters c++]]></category>
		<category><![CDATA[templates in c++]]></category>
		<category><![CDATA[types of templates in c++]]></category>
		<category><![CDATA[what is a template in c programming]]></category>
		<category><![CDATA[what is class template in c language]]></category>
		<category><![CDATA[what is function template in c]]></category>
		<category><![CDATA[what is function template in c plus plus]]></category>
		<category><![CDATA[what is function template in c++ with example]]></category>
		<category><![CDATA[what is template class t in c++]]></category>
		<category><![CDATA[what is template in c plus plus]]></category>
		<category><![CDATA[what is template in c++]]></category>
		<category><![CDATA[what is template in computer]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4805</guid>

					<description><![CDATA[In C++ a template is a simple and yet very powerful tool. We don’t need to write the same code for different data types because it is simple idea to pass data type as a parameter. Rather than maintaining and writing the multiple codes, we can write one sort () and pass data type as [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In C++ a template is a simple and yet very powerful tool.</li>
<li style="text-align: justify;">We don’t need to write the same code for different data types because it is simple idea to pass data type as a parameter.</li>
<li style="text-align: justify;">Rather than maintaining and writing the multiple codes, we can write one sort () and pass data type as a parameter.</li>
<li style="text-align: justify;">At compiler time templates are expanded, hence this is like macros.</li>
<li style="text-align: justify;">At C++ there are two types of support templates, they are ‘template’ and ‘typename’.</li>
<li style="text-align: justify;">The difference is, the compiler does type checking before template expansion and the idea is source code contains only function/class, but compiled code may contain multiple copies of same function/class.</li>
<li>Templates can be represented in two ways they are Function templates and Class templates.</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4806 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C.png" alt="" width="1800" height="835" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C.png 1800w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C-300x139.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C-1024x475.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C-768x356.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C-1536x713.png 1536w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C-390x181.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C-820x380.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/templates-C-1180x547.png 1180w" sizes="(max-width: 1800px) 100vw, 1800px" /></p>
<h2 id="function-template">Function Template</h2>
<ul>
<li>Generic functions use the concept of function template and it defines a set of operations that can be applied to the various types of data.</li>
<li>The function will operate on depends on the type of the data passed as a parameter.</li>
<li>It can be implemented to an array of floats or array of integers, quick sorting algorithm is implemented using a generic function.</li>
<li>Using keyword template generic function is created and template defines what function will do.</li>
</ul>
<h2 id="sample-code">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;iostream&gt;  <br/>using namespace std;  <br/>template&lt;class T&gt; T add(T &amp;a,T &amp;b)  <br/>{  <br/>    T result = a+b;  <br/>    return result;  <br/>      <br/>}  <br/>int main()  <br/>{  <br/>  int i =2;  <br/>  int j =3;  <br/>  float m = 2.3;  <br/>  float n = 1.2;  <br/>  cout&lt;&lt;&quot;Addition of i and j is :&quot;&lt;&lt;add(i,j);  <br/>  cout&lt;&lt;&#039;\n&#039;;  <br/>  cout&lt;&lt;&quot;Addition of m and n is :&quot;&lt;&lt;add(m,n);  <br/>  return 0;  <br/>}  </code></pre> </div>
<h2 id="output">Output</h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4807" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-template.png" alt="" width="1438" height="207" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-template.png 1438w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-template-300x43.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-template-1024x147.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-template-768x111.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-template-390x56.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-template-820x118.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-template-1180x170.png 1180w" sizes="(max-width: 1438px) 100vw, 1438px" /></p>
<h2 id="class-template">Class Template</h2>
<ul>
<li>Class template is also similar to function template.</li>
<li>If class uses the concept of template, then the class is known as generic class.</li>
<li>In class template Ttype is a placeholder name which will be determined when the class is instantiated.</li>
<li>We can define one or more than generic data type using a comma-separated list. It can be used inside the class body.</li>
</ul>
<h2 id="sample-code-2"><strong>Sample Code</strong></h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;iostream&gt;  <br/><br/>using namespace std;  <br/><br/>template&lt;class T&gt;  <br/><br/>class A   <br/><br/>{  <br/><br/>    public:  <br/><br/>    T num1 = 5;  <br/><br/>    T num2 = 6;  <br/><br/>    void add()  <br/><br/>    {  <br/><br/>        std::cout &lt;&lt; &quot;Addition of num1 and num2 : &quot; &lt;&lt; num1+num2&lt;&lt;std::endl;  <br/><br/>    }  <br/><br/>      <br/><br/>};  <br/><br/>  <br/><br/>int main()  <br/><br/>{  <br/><br/>    A&lt;int&gt; d;  <br/><br/>    d.add();  <br/><br/>    return 0;  <br/><br/>}  </code></pre> </div>
<h2 id="output-2">Output</h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4808" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/class-template.png" alt="" width="1410" height="144" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/class-template.png 1410w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/class-template-300x31.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/class-template-1024x105.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/class-template-768x78.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/class-template-390x40.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/class-template-820x84.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/class-template-1180x121.png 1180w" sizes="(max-width: 1410px) 100vw, 1410px" /></p>
<p style="text-align: justify;">
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-template-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Stack in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-stack-in-c/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-stack-in-c/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 10:51:23 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[clear stack c++]]></category>
		<category><![CDATA[pop program in c++]]></category>
		<category><![CDATA[stack c++ example]]></category>
		<category><![CDATA[stack in c++ using array]]></category>
		<category><![CDATA[stack push]]></category>
		<category><![CDATA[stack push pop program in c++]]></category>
		<category><![CDATA[what is stack and queue in c++]]></category>
		<category><![CDATA[what is stack in c]]></category>
		<category><![CDATA[what is stack in c++ programming]]></category>
		<category><![CDATA[what is stack in c++ with example]]></category>
		<category><![CDATA[what is stack memory in c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4801</guid>

					<description><![CDATA[Stack is an abstract data structure that contains a collection of elements. It implements the Last In First Out (LIFO) mechanism this element is pushed at the end is popped out first. It uses an encapsulated object of either deque or vector or list as its underlying container, providing a specific set of member functions [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">Stack is an abstract data structure that contains a collection of elements.</li>
<li style="text-align: justify;">It implements the Last In First Out (LIFO) mechanism this element is pushed at the end is popped out first.</li>
<li style="text-align: justify;">It uses an encapsulated object of either deque or vector or list as its underlying container, providing a specific set of member functions to access its elements.</li>
<li style="text-align: justify;">Stack class is a container adapter and container objects hold data of a similar data type.</li>
<li style="text-align: justify;">From various sequence containers we can create a stack.</li>
<li style="text-align: justify;">By default, deque container will be used, if there is no container is provided.</li>
<li style="text-align: justify;">It cannot be used to manipulate, because container adapters don’t support iterators.</li>
<li style="text-align: justify;">In stack Type is the Type of element contained and it can be any valid C++ type or even a user-defined type.</li>
<li style="text-align: justify;">In stack containeris the Type of underlying container object.</li>
<li style="text-align: justify;">Here three types of member types, they are:
<ul>
<li>Value_type- The first template parameter and donates the element types.</li>
<li>Container_type- The second template parameter and denotes the underlying container type.</li>
<li>Size_type- It is an unsigned integral type.</li>
</ul>
</li>
</ul>
<h2 id="syntax"><strong>Syntax</strong></h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">template &lt;class Type, class Container = deque&lt;Type&gt; &gt; class stack;</code></pre> </div>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4802 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-structure-cpp.png" alt="" width="1068" height="713" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-structure-cpp.png 1068w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-structure-cpp-300x200.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-structure-cpp-1024x684.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-structure-cpp-768x513.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-structure-cpp-390x260.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-structure-cpp-820x547.png 820w" sizes="(max-width: 1068px) 100vw, 1068px" /></p>
<h2 id="sample-code">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;iostream&gt;  <br/>#include &lt;stack&gt;  <br/>using namespace std;  <br/>void newstack(stack &lt;int&gt; ss)  <br/>{  <br/>    stack &lt;int&gt; sg = ss;  <br/>    while (!sg.empty())  <br/>    {  <br/>        cout &lt;&lt; &#039;\t&#039; &lt;&lt; sg.top();  <br/>        sg.pop();  <br/>    }  <br/>    cout &lt;&lt; &#039;\n&#039;;  <br/>}  <br/>int main ()  <br/>{  <br/>    stack &lt;int&gt; newst;  <br/>    newst.push(55);  <br/>    newst.push(44);  <br/>    newst.push(33);  <br/>    newst.push(22);  <br/>    newst.push(11);  <br/>  <br/>    cout &lt;&lt; &quot;The stack newst is : &quot;;  <br/>    newstack(newst);  <br/>    cout &lt;&lt; &quot;\n newst.size() : &quot; &lt;&lt; newst.size();  <br/>    cout &lt;&lt; &quot;\n newst.top() : &quot; &lt;&lt; newst.top();  <br/>    cout &lt;&lt; &quot;\n newst.pop() : &quot;;  <br/>    newst.pop();  <br/>    newstack(newst);   <br/>    return 0;  <br/>}  </code></pre> </div>
<h2 id="output">Output</h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4803" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack.png" alt="" width="1423" height="361" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack.png 1423w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-300x76.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-1024x260.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-768x195.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-390x99.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-820x208.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/stack-1180x299.png 1180w" sizes="(max-width: 1423px) 100vw, 1423px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-stack-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Pointers in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-pointers-in-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-pointers-in-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 09:41:33 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[c++ pointer]]></category>
		<category><![CDATA[c++ pointers]]></category>
		<category><![CDATA[c++ pointers with examples]]></category>
		<category><![CDATA[pointers in c]]></category>
		<category><![CDATA[pointers in c++/c++ with examples]]></category>
		<category><![CDATA[smart pointers in c++]]></category>
		<category><![CDATA[types of pointers in c]]></category>
		<category><![CDATA[what is pointer in c plus plus]]></category>
		<category><![CDATA[what is pointer in c++]]></category>
		<category><![CDATA[what is pointer in c++ definition]]></category>
		<category><![CDATA[what is pointer in c++ explain with example]]></category>
		<category><![CDATA[what is pointer in c++ syntax]]></category>
		<category><![CDATA[what is pointer in c++ types]]></category>
		<category><![CDATA[what is pointer in c++ with example]]></category>
		<category><![CDATA[what is pointers in c++ language]]></category>
		<category><![CDATA[what is pointers in c++ programming]]></category>
		<category><![CDATA[what is pointers in c++ with example]]></category>
		<category><![CDATA[what is pointers in cpp]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4798</guid>

					<description><![CDATA[Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create and manipulate dynamic data structures. It defines a pointer variable and its general declaration in C/C++ has the format. Using unary operator (&#38;) assigning the address of a variable to a pointer which returns the address [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create and manipulate dynamic data structures.</li>
<li style="text-align: justify;">It defines a pointer variable and its general declaration in C/C++ has the format.</li>
<li style="text-align: justify;">Using unary operator (&amp;) assigning the address of a variable to a pointer which returns the address of that variable.</li>
<li style="text-align: justify;">Using unary operator (*) accessing the value stored in the address which returns the value of the variable located at the address specified by its operand.</li>
<li style="text-align: justify;">When we increment a pointer, we increase the pointer by the size of data type to which it points, this is the reason data type to a pointer is knows how many bytes the data is stored inside.</li>
</ul>
<h2 id="syntax">Syntax</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">datatype *var_name; <br/>int *ptr;</code></pre> </div>
<h2 id="sample-code">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;iostream&gt;<br/>using namespace std;<br/>int main() {<br/>	int  x = 27;  <br/>	int  *ip;        <br/>	ip = &amp;x;       <br/>	cout &lt;&lt; &quot;Value of x is : &quot;;<br/>	cout &lt;&lt; x &lt;&lt; endl;<br/>	cout &lt;&lt; &quot;Value of ip is : &quot;;<br/>	cout &lt;&lt; ip&lt;&lt; endl;<br/>	cout &lt;&lt; &quot;Value of *ip is : &quot;;<br/>	cout &lt;&lt; *ip &lt;&lt; endl;<br/>	return 0;<br/>}</code></pre> </div>
<h2 id="output">Output</h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4799" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/pointers.png" alt="" width="541" height="150" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/pointers.png 541w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/pointers-300x83.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/pointers-390x108.png 390w" sizes="(max-width: 541px) 100vw, 541px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-pointers-in-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Overloading ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-overloading/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-overloading/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 08:06:07 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[c++ function overloading]]></category>
		<category><![CDATA[c++ operator overloading with examples]]></category>
		<category><![CDATA[c++ overloading]]></category>
		<category><![CDATA[function overloading]]></category>
		<category><![CDATA[function overloading in c++]]></category>
		<category><![CDATA[operator overloading in c++]]></category>
		<category><![CDATA[what is overloading in c++]]></category>
		<category><![CDATA[what is overloading in c++ with example]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4794</guid>

					<description><![CDATA[If a single object behaves in many ways, it is known as overloading. It provides different versions of the same function while a single object has the same name. C++ facilitates you to specify more than one definition for an operator or a function in the same scope. Overloading consists of two types, they are: Operator [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">If a single object behaves in many ways, it is known as overloading.</li>
<li style="text-align: justify;">It provides different versions of the same function while a single object has the same name.</li>
<li style="text-align: justify;"><a href="https://www.wikitechy.com/tutorials/c++/">C++</a> facilitates you to specify more than one definition for an operator or a function in the same scope.</li>
<li style="text-align: justify;">Overloading consists of two types, they are:
<ul>
<li>Operator Overloading</li>
<li>Function Overloading</li>
</ul>
</li>
</ul>
<h2 id="operator-overloading" style="text-align: justify;">Operator Overloading</h2>
<ul style="text-align: justify;">
<li>Operator overloading is otherwise known as <strong>compile-time polymorphism</strong> in which a standard operator is overloaded to provide a user-defined definition to it.</li>
<li><strong>&#8216;+&#8217; operator</strong> is overloaded to perform the addition operation on data types such as float, int, etc.</li>
<li>In following functions operator overloading can be implemented such as <strong>Member function, Non-Member function, Friend Function.</strong></li>
</ul>
<h3 id="sample-code" style="text-align: justify;">Sample Code</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;    <br/>class Test    <br/>{    <br/>   private:    <br/>      int num;    <br/>   public:    <br/>       Test(): num(8){}    <br/>       void operator ++()         {     <br/>          num = num+2;     <br/>       }    <br/>       void Print() {     <br/>           cout&lt;&lt;&quot;The Count is: &quot;&lt;&lt;num;     <br/>       }    <br/>};    <br/>int main()    <br/>{    <br/>    Test tt;    <br/>    ++tt;  // calling of a function &quot;void operator ++()&quot;    <br/>    tt.Print();    <br/>    return 0;    <br/>}  </code></pre> </div>
<h3 id="output" style="text-align: justify;">Output</h3>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4795" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/operator-overloading.png" alt="" width="1437" height="175" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/operator-overloading.png 1437w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/operator-overloading-300x37.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/operator-overloading-1024x125.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/operator-overloading-768x94.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/operator-overloading-390x47.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/operator-overloading-820x100.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/operator-overloading-1180x144.png 1180w" sizes="(max-width: 1437px) 100vw, 1437px" /></p>
<h2 id="function-overloading" style="text-align: justify;">Function Overloading</h2>
<ul style="text-align: justify;">
<li>Function overloading is a type of compile-time polymorphism which can define a family of functions with the same name.</li>
<li>The function would perform different operations based on the argument list in the function call.</li>
<li>In argument list function to be invoked depends on the number of arguments and the type of the arguments.</li>
</ul>
<h3 id="sample-code-2" style="text-align: justify;">Sample Code</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;    <br/>class Cal {    <br/>    public:    <br/>static int add(int a,int b){      <br/>        return a + b;      <br/>    }      <br/>static int add(int a, int b, int c)      <br/>    {      <br/>        return a + b + c;      <br/>    }      <br/>};     <br/>int main(void) {    <br/>    Cal C;                                                    //     class object declaration.   <br/>    cout&lt;&lt;C.add(10, 20)&lt;&lt;endl;      <br/>    cout&lt;&lt;C.add(12, 20, 23);     <br/>   return 0;    <br/>}    </code></pre> </div>
<h3 id="output-2" style="text-align: justify;">Output</h3>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4796" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-overloading.png" alt="" width="1423" height="211" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-overloading.png 1423w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-overloading-300x44.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-overloading-1024x152.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-overloading-768x114.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-overloading-390x58.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-overloading-820x122.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/function-overloading-1180x175.png 1180w" sizes="(max-width: 1423px) 100vw, 1423px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-overloading/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is bool data in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-bool-data-in-c/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-bool-data-in-c/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Fri, 19 Aug 2022 07:40:38 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[bool data type in c++]]></category>
		<category><![CDATA[boolean array in c++]]></category>
		<category><![CDATA[boolean in c++]]></category>
		<category><![CDATA[boolean in c++ with example]]></category>
		<category><![CDATA[c++ boolean]]></category>
		<category><![CDATA[c++ boolean data types]]></category>
		<category><![CDATA[use of bool in c++]]></category>
		<category><![CDATA[what is bool data type in c++]]></category>
		<category><![CDATA[What is boolean in C++]]></category>
		<category><![CDATA[working with boolean in c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4790</guid>

					<description><![CDATA[In C++ Boolean data type is defined using the bool keyword. This servers as an easy and convenient datatype for programmers to manage and write conditional statements using a boolean value, rather than an int. Usually true or false are assigned to boolean variables as their default numerical values. In C++ any numerical value can [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In C++ Boolean data type is defined using the bool keyword.</li>
<li style="text-align: justify;">This servers as an easy and convenient datatype for programmers to manage and write conditional statements using a boolean value, rather than an int.</li>
<li style="text-align: justify;">Usually true or false are assigned to boolean variables as their default numerical values.</li>
<li style="text-align: justify;">In C++ any numerical value can be assigned to a boolean variable, all values other than 00 are considered to be true and stored as 1, while 0 is considered to be false.</li>
<li style="text-align: justify;">In certain situations, they are provided to provide better control as well as for providing conveniences to C++ programmers.</li>
<li style="text-align: justify;">At C++ language the values <em>true</em><em> </em>or <em>false</em> have been added as keywords.</li>
<li style="text-align: justify;">We can use bool type values or variables true and false in mathematical expressions.</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4791 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-type.png" alt="" width="1219" height="548" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-type.png 1219w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-type-300x135.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-type-1024x460.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-type-768x345.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-type-390x175.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-type-820x369.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-type-1180x530.png 1180w" sizes="(max-width: 1219px) 100vw, 1219px" /></p>
<ul>
<li>In numerical expression a boolean variable in C++ can be used as well.</li>
<li>if a bool variable is equal to true (or any numeric value other than 0), 1is assigned to it and taken as 1 during the evaluation of the expression; 0 and false will be taken as 0.</li>
</ul>
<h2 id="sample-code">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;iostream&gt;<br/>using namespace std;<br/><br/>int main() {<br/>  bool x = 10;  // x = 1;<br/>  bool y = false;  // y = 0;<br/><br/>  // Using bool in a numeric expression:<br/>  cout &lt;&lt; 2 * (x + y) &lt;&lt; endl;<br/>  <br/>  return 0;<br/>}</code></pre> </div>
<h2 id="output">Output</h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4792" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-data.png" alt="" width="1150" height="168" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-data.png 1150w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-data-300x44.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-data-1024x150.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-data-768x112.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-data-390x57.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/boolean-data-820x120.png 820w" sizes="(max-width: 1150px) 100vw, 1150px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-bool-data-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is a Virtual Destructor ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-a-virtual-destructor/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-a-virtual-destructor/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 12:31:05 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[c++ virtual destructor]]></category>
		<category><![CDATA[can we have virtual destructor]]></category>
		<category><![CDATA[pure virtual destructor in c++]]></category>
		<category><![CDATA[use of virtual destructor in c++]]></category>
		<category><![CDATA[virtual destructor]]></category>
		<category><![CDATA[virtual destructor c++]]></category>
		<category><![CDATA[virtual destructor default]]></category>
		<category><![CDATA[virtual destructor in c++]]></category>
		<category><![CDATA[what is virtual destructor]]></category>
		<category><![CDATA[what is virtual destructor in c++]]></category>
		<category><![CDATA[when to use virtual destructors]]></category>
		<category><![CDATA[why do we need virtual destructors]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4781</guid>

					<description><![CDATA[In C++ destructor is a member function of a class used to free the space occupied by or delete an object of the class that goes out of scope. In class destructor has the same name as the name of the constructor function, but the destructor uses a tilde (~)sign before its function name. It is [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In C++ destructor is a member function of a class used to free the space occupied by or delete an object of the class that goes out of scope.</li>
<li style="text-align: justify;">In class destructor has the same name as the name of the constructor function, but the destructor uses a tilde <strong>(~)</strong>sign before its function name.</li>
<li style="text-align: justify;">It is used to free up the memory space allocated by derived class object or instance while deleting instances of the derived class using a base class pointer object.</li>
<li style="text-align: justify;">A derived class or base class destructor use the <strong>virtual </strong>keyword that ensures both classes destructor will be called at run time.</li>
<li style="text-align: justify;">First it calls the derived class and then base class to release the space occupied by both destructors.</li>
<li style="text-align: justify;">If an object in the class goes out of scope or the execution of the main() function is about to end, automatically a destructor is called into the program to free up the space occupied by the class’s destructor function.</li>
<li style="text-align: justify;">If a pointer object of the base class is deleted that points to the derived class, only the parent class destructor is called due to the early bind by the compiler.</li>
<li style="text-align: justify;">In main function if the compiler compiles the code, it calls a pointer object that refers to the base class.</li>
<li style="text-align: justify;">It executes the base class’s constructor() function and then moves to the derived class’s constructor() function and deletes the pointer object occupied by the base class&#8217;s destructor and the derived class&#8217;s destructor.</li>
<li style="text-align: justify;">In program base class pointer only removes the base class&#8217;s destructor without calling the derived class&#8217;s destructor</li>
</ul>
<h2 id="sample-code">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;  <br/>class Base  <br/>{  <br/>    public:  <br/>    Base() // Constructor member function.    <br/>{  <br/>    cout &lt;&lt; &quot;\n Constructor Base class&quot;;  // It prints first.  <br/>}  <br/> virtual ~Base() // Define the virtual destructor function to call the Destructor Derived function.  <br/>{  <br/>    cout &lt;&lt; &quot;\n Destructor Base class&quot;;  /  <br/>}  <br/>};  <br/>// Inheritance concept  <br/>class Derived: public Base   <br/>{  <br/>    public:  <br/>    Derived() // Constructor function.  <br/>{  <br/>    cout &lt;&lt; &quot;\n Constructor Derived class&quot; ; /* After print the Constructor Base, now it will prints. */  <br/>}  <br/> ~Derived() // Destructor function   <br/>{  <br/>    cout &lt;&lt; &quot;\n Destructor Derived class&quot;; /* The virtual Base Class? Destructor calls it before calling the Base Class Destructor. */  <br/>}         <br/>};  <br/>int main()  <br/>{  <br/>    Base *bptr = new Derived; // A pointer object reference the Base class.  <br/>    delete bptr; // Delete the pointer object.  <br/>}  </code></pre> </div>
<h2 id="output">Output</h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4782" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-destructor.png" alt="" width="1394" height="391" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-destructor.png 1394w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-destructor-300x84.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-destructor-1024x287.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-destructor-768x215.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-destructor-390x109.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-destructor-820x230.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/virtual-destructor-1180x331.png 1180w" sizes="(max-width: 1394px) 100vw, 1394px" /></p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-a-virtual-destructor/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Iterator in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-iterator-in-c/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-iterator-in-c/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 11:19:55 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[auto iterator c++]]></category>
		<category><![CDATA[c++ iterator implementation]]></category>
		<category><![CDATA[c++ iterators]]></category>
		<category><![CDATA[introduction to iterators in c++]]></category>
		<category><![CDATA[iterator arithmetic c++]]></category>
		<category><![CDATA[iterators]]></category>
		<category><![CDATA[iterators c++ example]]></category>
		<category><![CDATA[iterators in c++]]></category>
		<category><![CDATA[list iterator c++]]></category>
		<category><![CDATA[types of iterators in c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4777</guid>

					<description><![CDATA[An iterator is an object like a pointer that points to an element inside the container. Iterator can use to move through the contents of the container. We can access the content at that particular location using them and it can be visualized as something similar to a pointer pointing to some location. It plays [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">An iterator is an object like a pointer that points to an element inside the container.</li>
<li style="text-align: justify;">Iterator can use to move through the contents of the container.</li>
<li style="text-align: justify;">We can access the content at that particular location using them and it can be visualized as something similar to a pointer pointing to some location.</li>
<li style="text-align: justify;">It plays a critical role while connecting algorithm with containers along with the manipulation of data stored inside the containers.</li>
<li style="text-align: justify;">Pointer is a most obvious form of an iterator.</li>
<li style="text-align: justify;">In an array pointer can point to elements and using increment operator (++) it can iterate through them.</li>
<li style="text-align: justify;">All iterator doesn’t have similar functionality as that of pointers.</li>
<li style="text-align: justify;">Depending upon the functionality of iterators they can be classified into five categories, they are:
<ul>
<li>Input iterator</li>
<li>Output iterator</li>
<li>Forward iterator</li>
<li>Bidirectional iterator</li>
<li>Random access iterator</li>
</ul>
</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4779 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-iterator.png" alt="" width="1338" height="806" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-iterator.png 1338w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-iterator-300x181.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-iterator-1024x617.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-iterator-768x463.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-iterator-390x235.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-iterator-820x494.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-iterator-1180x711.png 1180w" sizes="(max-width: 1338px) 100vw, 1338px" /></p>
<h2 id="input-iterator" style="text-align: justify;">Input iterator</h2>
<ul style="text-align: justify;">
<li>They have limited functionality and weakest of all iterators.</li>
<li>In single-pass algorithms it can be used.</li>
<li>Those algorithms which process the container sequentially, such that no element is accessed more than once.</li>
</ul>
<h2 id="output-iterator" style="text-align: justify;">Output iterator</h2>
<ul style="text-align: justify;">
<li>It is also like input operators, they are also very limited in their functionality and can only be used in single-pass algorithm, but not for accessing elements, but for being assigned elements.</li>
</ul>
<h2 id="forward-iterator" style="text-align: justify;">Forward iterator</h2>
<ul style="text-align: justify;">
<li>It is higher in hierarchy than input iterator and output iterator and contain all the features present in these two iterators</li>
<li>As name suggests, they can also only move in a forward direction and that too one step at a time.</li>
</ul>
<h2 id="bidirectional-iterator" style="text-align: justify;">Bidirectional iterator</h2>
<ul style="text-align: justify;">
<li>It has all the features of forward iterators along with the fact that they overcome the drawback of forward iterators, in both the directions they can move, hence their name is Bidirectional iterators.</li>
</ul>
<h2 id="random-access-iterator" style="text-align: justify;">Random Access iterator</h2>
<ul style="text-align: justify;">
<li>It is the most powerful iterators and they are not limited to moving sequentially, as their name suggests, they can randomly access any element inside the container.</li>
</ul>
<h3 id="sample-code" style="text-align: justify;"><strong>Sample Code</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;iostream&gt;<br/><br/>    #include &lt;vector&gt;<br/><br/>    using namespace std;<br/><br/>    int main()<br/><br/>    {<br/><br/>            // Declaring a vector<br/><br/>            vector&lt;int&gt; v = { 1, 2, 3 };<br/><br/><br/><br/><br/>           // Declaring an iterator<br/><br/>           vector&lt;int&gt;::iterator i;<br/><br/><br/><br/><br/>           int j;<br/><br/><br/><br/><br/>           cout &lt;&lt; &quot;Without iterators = &quot;;<br/><br/>     <br/><br/>           // Accessing the elements without using iterators<br/><br/>           for (j = 0; j &lt; 3; ++j)<br/><br/>        {<br/><br/>          cout &lt;&lt; v[j] &lt;&lt; &quot; &quot;;<br/><br/>        }<br/><br/><br/><br/><br/>          cout &lt;&lt; &quot;\nWith iterators = &quot;;<br/><br/>     <br/><br/>          // Accessing the elements using iterators<br/><br/>         for (i = v.begin(); i != v.end(); ++i)<br/><br/>      {<br/><br/>          cout &lt;&lt; *i &lt;&lt; &quot; &quot;;<br/><br/>      }<br/><br/><br/><br/><br/>         // Adding one more element to vector<br/><br/>         v.push_back(4);<br/><br/><br/><br/><br/>         cout &lt;&lt; &quot;\nWithout iterators = &quot;;<br/><br/>     <br/><br/>         // Accessing the elements without using iterators<br/><br/>        for (j = 0; j &lt; 4; ++j)<br/><br/>     {<br/><br/>         cout &lt;&lt; v[j] &lt;&lt; &quot; &quot;;<br/><br/>     }<br/><br/><br/><br/><br/>         cout &lt;&lt; &quot;\nWith iterators = &quot;;<br/><br/>     <br/><br/>        // Accessing the elements using iterators<br/><br/>       for (i = v.begin(); i != v.end(); ++i)<br/><br/>    {<br/><br/>        cout &lt;&lt; *i &lt;&lt; &quot; &quot;;<br/><br/>    }<br/><br/><br/><br/><br/>    return 0;<br/><br/>  }</code></pre> </div>
<h3 id="output" style="text-align: justify;"><strong>Output</strong></h3>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4778 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/iterators.png" alt="" width="673" height="320" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/iterators.png 673w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/iterators-300x143.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/iterators-390x185.png 390w" sizes="(max-width: 673px) 100vw, 673px" /></p>
<p style="text-align: justify;"><strong> </strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-iterator-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is destructor in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-destructor-in-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-destructor-in-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 10:51:24 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[c++ destructor]]></category>
		<category><![CDATA[c++ destructors]]></category>
		<category><![CDATA[characteristics of destructors in c++]]></category>
		<category><![CDATA[constructor and destructor in c++]]></category>
		<category><![CDATA[destructor in c++]]></category>
		<category><![CDATA[destructor in c++ example program with output]]></category>
		<category><![CDATA[destructors in c++]]></category>
		<category><![CDATA[how to call destructor C++]]></category>
		<category><![CDATA[types of destructor in c++]]></category>
		<category><![CDATA[use of destructor in c++]]></category>
		<category><![CDATA[what is destructor in c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4774</guid>

					<description><![CDATA[In C++ destructor is an instance member function which is invoked automatically whenever an object is going to be destroyed. A destructor meaning is the last function that is going to be called before an object is destroyed. If the object is created by using new or the constructor uses new to allocate memory which [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In C++ destructor is an instance member function which is invoked automatically whenever an object is going to be destroyed.</li>
<li style="text-align: justify;">A destructor meaning is the last function that is going to be called before an object is destroyed.</li>
<li style="text-align: justify;">If the object is created by using new or the constructor uses new to allocate memory which resides in the heap memory or the free store, the destructor should use delete to free the memory, the thing is to be noted here.</li>
<li style="text-align: justify;">When the objects are destroyed, destructor function is automatically invoked.</li>
<li style="text-align: justify;">Destructor does not have arguments and it cannot be declared as constant or static.</li>
<li style="text-align: justify;">Destructor cannot become a member of the union while with an object of a class.</li>
<li style="text-align: justify;">The programmer cannot access the address of destructor and in public section of class destructor should be declared.</li>
<li style="text-align: justify;">If the object goes out of scope, destructor function is called automatically were the function ends, the program ends, a block containing local variables ends, a delete operator is called.</li>
<li style="text-align: justify;">Destructors have same name as the class preceded by a tilde (~) it doesn’t take any argument and return anything.</li>
</ul>
<h2 id="sample-code" style="text-align: justify;">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include&lt;iostream&gt;<br/>               using namespace std;<br/>              class Demo {<br/>                   private:<br/>                   int num1, num2;<br/>                   public:<br/>                   	Demo(int n1, int n2) {<br/>                                   cout&lt;&lt;&quot;Inside Constructor&quot;&lt;&lt;endl;<br/>                                   num1 = n1;<br/>                                   num2 = n2;<br/>                              }<br/>                             void display() {<br/>                                   cout&lt;&lt;&quot;num1 = &quot;&lt;&lt; num1 &lt;&lt;endl;<br/>                                   cout&lt;&lt;&quot;num2 = &quot;&lt;&lt; num2 &lt;&lt;endl;<br/>                             }<br/>                         ~Demo() {<br/>                                  cout&lt;&lt;&quot;Inside Destructor&quot;;<br/>                            }<br/>                       };<br/>                      int main() {<br/>                      Demo obj1(30, 50);<br/>                      obj1.display();<br/>                      return 0;<br/>                      }</code></pre> </div>
<h2 id="output" style="text-align: justify;">Output</h2>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4775" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/destructor.png" alt="" width="1137" height="311" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/destructor.png 1137w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/destructor-300x82.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/destructor-1024x280.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/destructor-768x210.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/destructor-390x107.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/destructor-820x224.png 820w" sizes="(max-width: 1137px) 100vw, 1137px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-destructor-in-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Constructor in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-constructor-in-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-constructor-in-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 10:41:19 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[c++ class constructor and destructor]]></category>
		<category><![CDATA[c++ constructors]]></category>
		<category><![CDATA[constructor and destructor in c++]]></category>
		<category><![CDATA[Constructor in c++ and its types]]></category>
		<category><![CDATA[constructor overloading in c++]]></category>
		<category><![CDATA[constructors in c++]]></category>
		<category><![CDATA[types of constructor in c++]]></category>
		<category><![CDATA[types of constructor in c++ with example]]></category>
		<category><![CDATA[use of constructor in c++]]></category>
		<category><![CDATA[what is copy constructor in c++]]></category>
		<category><![CDATA[what is default constructor in c++]]></category>
		<category><![CDATA[what is parameterized constructor in c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4768</guid>

					<description><![CDATA[In C++ constructor is a special type of member function of a class which initializes objects of a class. Constructor is automatically called when object is created in C++. It does not have any return type because it is special member function of the class. In public section of class and it has same name [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In C++ constructor is a special type of member function of a class which initializes objects of a class.</li>
<li style="text-align: justify;">Constructor is automatically called when object is created in C++.</li>
<li style="text-align: justify;">It does not have any return type because it is special member function of the class.</li>
<li style="text-align: justify;">In public section of class and it has same name as the class itself.</li>
<li style="text-align: justify;">Copy and parameterized constructors have input arguments, by default constructors don’t have input argument however.</li>
<li style="text-align: justify;">C++ compiler generates a default constructor for object, if we do not specify a constructor.</li>
<li style="text-align: justify;">In constructor there are three types, they are <strong>default constructor, parameterized constructor, copy constructor.</strong></li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4772 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c.png" alt="" width="1759" height="709" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c.png 1759w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c-300x121.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c-1024x413.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c-768x310.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c-1536x619.png 1536w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c-390x157.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c-820x331.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/constructor-in-c-1180x476.png 1180w" sizes="(max-width: 1759px) 100vw, 1759px" /></p>
<h2 id="default-constructor">Default Constructor</h2>
<ul>
<li>It is the constructor which has no parameters and doesn’t take any argument.</li>
</ul>
<h3 id="sample-code"><strong>Sample Code</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;<br/><br/>class construct<br/><br/>{<br/><br/>public:<br/><br/>    int a, b;<br/><br/><br/><br/><br/>    // Default Constructor<br/><br/>    construct()<br/><br/>    {<br/><br/>        a = 30;<br/><br/>        b = 40;<br/><br/>    }<br/><br/>};<br/><br/><br/><br/><br/>int main()<br/><br/>{<br/><br/>    // Default constructor called automatically<br/><br/>    // when the object is created<br/><br/>    construct c;<br/><br/>    cout &lt;&lt; &quot;a: &quot; &lt;&lt; c.a &lt;&lt; endl<br/><br/>         &lt;&lt; &quot;b: &quot; &lt;&lt; c.b;<br/><br/>    return 1;<br/><br/>}</code></pre> </div>
<h3 id="output"><strong>Output</strong></h3>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4769" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/default-constructor.png" alt="" width="969" height="178" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/default-constructor.png 969w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/default-constructor-300x55.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/default-constructor-768x141.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/default-constructor-390x72.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/default-constructor-820x151.png 820w" sizes="(max-width: 969px) 100vw, 969px" /></p>
<h2 id="parameterized-constructor">Parameterized Constructor</h2>
<ul>
<li>It is possible to pass arguments to constructors and these arguments help initialize an object when it is created typically.</li>
</ul>
<h3 id="sample-code-2"><strong>Sample Code</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;<br/><br/>class Point<br/><br/>{<br/><br/>private:<br/><br/>    int x, y;<br/><br/><br/><br/><br/>public:<br/><br/>    // Parameterized Constructor<br/><br/>    Point(int x1, int y1)<br/><br/>    {<br/><br/>        x = x1;<br/><br/>        y = y1;<br/><br/>    }<br/><br/><br/><br/><br/>    int getX()<br/><br/>    {<br/><br/>        return x;<br/><br/>    }<br/><br/>    int getY()<br/><br/>    {<br/><br/>        return y;<br/><br/>    }<br/><br/>};<br/><br/><br/><br/><br/>int main()<br/><br/>{<br/><br/>    // Constructor called<br/><br/>    Point p1(10, 15);<br/><br/><br/><br/><br/>    // Access values assigned by constructor<br/><br/>    cout &lt;&lt; &quot;p1.x = &quot; &lt;&lt; p1.getX() &lt;&lt; &quot;, p1.y = &quot; &lt;&lt; p1.getY();<br/><br/><br/><br/><br/>    return 0;<br/><br/>}</code></pre> </div>
<h3 id="output-2"><strong> O</strong><strong>utput</strong></h3>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4770" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/parameterized-constructor.png" alt="" width="934" height="181" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/parameterized-constructor.png 934w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/parameterized-constructor-300x58.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/parameterized-constructor-768x149.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/parameterized-constructor-390x76.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/parameterized-constructor-820x159.png 820w" sizes="(max-width: 934px) 100vw, 934px" /></p>
<h2 id="copy-constructor">Copy Constructor</h2>
<ul>
<li>It is a member function which initializes an object using another object of the same class.</li>
</ul>
<h3 id="sample-code-3"><strong>Sample Code</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;<br/><br/>class point<br/><br/>{<br/><br/>private:<br/><br/>  double x, y;<br/><br/><br/><br/><br/>public:<br/><br/>   <br/><br/>  // Non-default Constructor &amp;<br/><br/>  // default Constructor<br/><br/>  point (double px, double py)<br/><br/>  {<br/><br/>    x = px, y = py;<br/><br/>  }<br/><br/>};<br/><br/><br/><br/><br/>int main(void)<br/><br/>{<br/><br/><br/><br/><br/>  // Define an array of size<br/><br/>  // 10 &amp; of type point<br/><br/>  // This line will cause error<br/><br/>  point a[10];<br/><br/><br/><br/><br/>  // Remove above line and program<br/><br/>  // will compile without error<br/><br/>  point b = point(5, 6);<br/><br/>}</code></pre> </div>
<h3 id="output-3"><strong>Output</strong></h3>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4771" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/copy-constructor.png" alt="" width="1053" height="189" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/copy-constructor.png 1053w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/copy-constructor-300x54.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/copy-constructor-1024x184.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/copy-constructor-768x138.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/copy-constructor-390x70.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/copy-constructor-820x147.png 820w" sizes="(max-width: 1053px) 100vw, 1053px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-constructor-in-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 10:21:17 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[basics concepts of c++ programming language]]></category>
		<category><![CDATA[c programming examples]]></category>
		<category><![CDATA[c++ basics]]></category>
		<category><![CDATA[c++ Introduction]]></category>
		<category><![CDATA[c++ tutorial]]></category>
		<category><![CDATA[introduction to c++ programming language]]></category>
		<category><![CDATA[learn c programming]]></category>
		<category><![CDATA[learn c++]]></category>
		<category><![CDATA[what is c++]]></category>
		<category><![CDATA[what is c++ used for]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4763</guid>

					<description><![CDATA[It is an object-oriented programming language that can be used to create high-performance applications. In 1985 C++ was developed by Bjarne Stroustrup as an extension of c program language. It gives a programmer’s high level of control over system memory and resources. This programming language is one of the world’s most popular language. Nowadays it can be [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">It is an object-oriented programming language that can be used to create high-performance applications.</li>
<li style="text-align: justify;">In 1985 <a href="https://www.wikitechy.com/tutorials/c++/">C++</a> was developed by Bjarne Stroustrup as an extension of c program language.</li>
<li style="text-align: justify;">It gives a programmer’s high level of control over system memory and resources.</li>
<li style="text-align: justify;">This programming language is one of the world’s most popular language.</li>
<li style="text-align: justify;">Nowadays it can be found in embedded systems, operating systems and Graphical User Interfaces.</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4764 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-cpp.png" alt="" width="1139" height="502" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-cpp.png 1139w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-cpp-300x132.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-cpp-1024x451.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-cpp-768x338.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-cpp-390x172.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/what-is-cpp-820x361.png 820w" sizes="(max-width: 1139px) 100vw, 1139px" /></p>
<ul style="text-align: justify;">
<li>C++ gives a clear structure to programs and allows code to be reused, lowering development costs because it is an Object-Oriented Programming language.</li>
<li>C++ is close to Java and C#, it makes easy for programmers to switch vice versa or C++.</li>
<li>It is used to develop browsers, games, operating systems and so on.</li>
</ul>
<h2 id="sample-code" style="text-align: justify;">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;iostream&gt;<br/>using namespace std;<br/><br/>int main() <br/>{<br/>  cout &lt;&lt; &quot;Welcome to Wikitechy&quot;;<br/>  return 0;<br/>}</code></pre> </div>
<h2 id="output" style="text-align: justify;">Output</h2>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4765 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/cpp.png" alt="" width="1227" height="347" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/cpp.png 1227w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/cpp-300x85.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/cpp-1024x290.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/cpp-768x217.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/cpp-390x110.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/cpp-820x232.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/cpp-1180x334.png 1180w" sizes="(max-width: 1227px) 100vw, 1227px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What are the different types of polymorphism in C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-are-the-different-types-of-polymorphism-in-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-are-the-different-types-of-polymorphism-in-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 07:58:19 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[C++ Polymorphism]]></category>
		<category><![CDATA[C++ Polymorphism with Example]]></category>
		<category><![CDATA[compile time polymorphism]]></category>
		<category><![CDATA[Encapsulation in C++]]></category>
		<category><![CDATA[function overloading in c++ polymorphism]]></category>
		<category><![CDATA[polymorphism in c++]]></category>
		<category><![CDATA[polymorphism with pointers in c++]]></category>
		<category><![CDATA[run time polymorphism in c++ program is mcq]]></category>
		<category><![CDATA[runtime polymorphism]]></category>
		<category><![CDATA[Types of Polymorphism and its Functions]]></category>
		<category><![CDATA[types of polymorphism in c++]]></category>
		<category><![CDATA[types of polymorphism in java]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4754</guid>

					<description><![CDATA[Polymorphism means multiple forms that means having more than one function with the same name but with different functionalities. In C++ program there are 2 types of polymorphism, they are: Compile-time polymorphism Run-time polymorphism Compile-time polymorphism At compile time which is implemented known as Compile-time polymorphism. It is otherwise known as static polymorphism. Method overloading [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">Polymorphism means multiple forms that means having more than one function with the same name but with different functionalities.</li>
<li style="text-align: justify;">In C++ program there are 2 types of polymorphism, they are:
<ul>
<li>Compile-time polymorphism</li>
<li>Run-time polymorphism</li>
</ul>
</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4761" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/polymorphism-in-cpp.png" alt="" width="1218" height="851" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/polymorphism-in-cpp.png 1218w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/polymorphism-in-cpp-300x210.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/polymorphism-in-cpp-1024x715.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/polymorphism-in-cpp-768x537.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/polymorphism-in-cpp-390x272.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/polymorphism-in-cpp-820x573.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/polymorphism-in-cpp-1180x824.png 1180w" sizes="(max-width: 1218px) 100vw, 1218px" /></p>
<h2 id="compile-time-polymorphism" style="text-align: justify;">Compile-time polymorphism</h2>
<ul style="text-align: justify;">
<li>At compile time which is implemented known as Compile-time polymorphism. It is otherwise known as static polymorphism.</li>
<li>Method overloading is also an example for compile-time polymorphism.</li>
<li>Method overloading which allows you to have more than one function with the same function name but with different functionality.</li>
</ul>
<h3 id="sample-code" style="text-align: justify;"><strong>Sample Code</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;  <br/><br/>class Multiply  <br/><br/>{  <br/><br/>   public:  <br/><br/>   int mul(int a,int b)  <br/><br/>   {  <br/><br/>       return(a*b);  <br/><br/>   }  <br/><br/>   int mul(int a,int b,int c)  <br/><br/>   {  <br/><br/>       return(a*b*c);  <br/><br/>  }  <br/><br/> };  <br/><br/>int main()  <br/><br/>{  <br/><br/>    Multiply multi;  <br/><br/>    int res1,res2;  <br/><br/>    res1=multi.mul(2,3);  <br/><br/>    res2=multi.mul(2,3,4);  <br/><br/>    cout&lt;&lt;&quot;\n&quot;;  <br/><br/>    cout&lt;&lt;res1;  <br/><br/>    cout&lt;&lt;&quot;\n&quot;;  <br/><br/>    cout&lt;&lt;res2;  <br/><br/>    return 0;  <br/><br/>}  </code></pre> </div>
<h3 id="output" style="text-align: justify;"><strong>Output</strong></h3>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4755" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/compile-time-polymorphism.png" alt="" width="1416" height="196" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/compile-time-polymorphism.png 1416w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/compile-time-polymorphism-300x42.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/compile-time-polymorphism-1024x142.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/compile-time-polymorphism-768x106.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/compile-time-polymorphism-390x54.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/compile-time-polymorphism-820x114.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/compile-time-polymorphism-1180x163.png 1180w" sizes="(max-width: 1416px) 100vw, 1416px" /></p>
<h2 id="run-time-polymorphism" style="text-align: justify;">Run-time polymorphism</h2>
<ul style="text-align: justify;">
<li>Run-time polymorphism is otherwise known as dynamic polymorphism.</li>
<li>Function overriding is an example of runtime polymorphism that means when the child class contains the method which is already present in the parent class.</li>
<li>In function overriding, parent and child class both contains the same function with the different definition.</li>
<li>The call to the function is determined at runtime is known as runtime polymorphism.</li>
</ul>
<h3 id="sample-code-2" style="text-align: justify;"><strong>Sample Code</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">using namespace std;  <br/><br/>class Base  <br/><br/>{ <br/><br/>    public:  <br/><br/>    virtual void show()  <br/><br/>    {  <br/><br/>        cout&lt;&lt;&quot;Wikitechy&quot;;  <br/><br/>     }  <br/><br/>};  <br/><br/>class Derived:public Base  <br/><br/>{  <br/><br/>    public:  <br/><br/>    void show()  <br/><br/>    {  <br/><br/>        cout&lt;&lt;&quot;Welcome to Wikitechy&quot;;  <br/><br/>    }  <br/><br/>};  <br/><br/>  <br/><br/>int main()  <br/><br/>{  <br/><br/>    Base* b;  <br/><br/>    Derived d;  <br/><br/>    b=&amp;d;  <br/><br/>    b-&gt;show();  <br/><br/>                return 0;  <br/><br/>}  </code></pre> </div>
<h3 id="output-2" style="text-align: justify;"><strong>Output</strong></h3>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4756" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/run-time-polymorphism.png" alt="" width="956" height="219" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/run-time-polymorphism.png 956w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/run-time-polymorphism-300x69.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/run-time-polymorphism-768x176.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/run-time-polymorphism-390x89.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/run-time-polymorphism-820x188.png 820w" sizes="(max-width: 956px) 100vw, 956px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-are-the-different-types-of-polymorphism-in-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What are the C++ Access Modifiers ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-are-the-cpp-access-modifiers/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-are-the-cpp-access-modifiers/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 06:50:59 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[access modifiers in c++]]></category>
		<category><![CDATA[access specifiers in c++ example]]></category>
		<category><![CDATA[class access modifiers in c++]]></category>
		<category><![CDATA[how many access specifiers in c++]]></category>
		<category><![CDATA[objective c access modifiers]]></category>
		<category><![CDATA[private access specifier in c++]]></category>
		<category><![CDATA[protected in c++]]></category>
		<category><![CDATA[public access specifier in c++]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4751</guid>

					<description><![CDATA[In java access modifiers is the accessibility or scope of a field, method, constructor, or class. The access specifiers are used to define how the variables and functions can be accessed outside the class. We can change the access level of constructors, fields, methods, and class by applying the access modifier. In C++ there are [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In java access modifiers is the accessibility or scope of a field, method, constructor, or class.</li>
<li style="text-align: justify;">The access specifiers are used to define how the variables and functions can be accessed outside the class.</li>
<li style="text-align: justify;">We can change the access level of constructors, fields, methods, and class by applying the access modifier.</li>
<li style="text-align: justify;">In C++ there are four types of access modifiers, they are:
<ul>
<li>Private</li>
<li>Public</li>
<li>Protected</li>
<li>Default</li>
</ul>
</li>
</ul>
<h2 id="private" style="text-align: justify;">Private</h2>
<ul style="text-align: justify;">
<li>The private modifier is only within the class and it cannot be accessed from outside the class.</li>
</ul>
<h3 id="sample-code" style="text-align: justify;">Sample Code</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">class A{  <br/><br/>private int data=40;  <br/><br/>private void msg(){System.out.println(&quot;Welcome to Wikitechy&quot;);}  <br/><br/>}  <br/><br/>  <br/><br/>public class Simple{  <br/><br/> public static void main(String args[]){  <br/><br/>   A obj=new A();  <br/><br/>   System.out.println(obj.data);//Compile Time Error  <br/><br/>   obj.msg();//Compile Time Error  <br/><br/>   }  <br/><br/>}  </code></pre> </div>
<h3 id="output" style="text-align: justify;">Output</h3>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4752" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier.png" alt="" width="883" height="187" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier.png 883w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-300x64.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-768x163.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-390x83.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-820x174.png 820w" sizes="(max-width: 883px) 100vw, 883px" /></p>
<h2 id="public" style="text-align: justify;">Public</h2>
<ul style="text-align: justify;">
<li>The public modifier is everywhere, and it can access from within the class, outside the class, within the package and outside the package.</li>
</ul>
<h3 id="sample-code-2" style="text-align: justify;">Sample Code</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">package pack;  <br/><br/>public class A{  <br/><br/>public void msg(){System.out.println(&quot;Welcome to Wikitechy&quot;);}  <br/><br/>}  </code></pre> </div>
<h3 id="output-2" style="text-align: justify;">Output</h3>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4752" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier.png" alt="" width="883" height="187" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier.png 883w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-300x64.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-768x163.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-390x83.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-820x174.png 820w" sizes="(max-width: 883px) 100vw, 883px" /></p>
<h2 id="protected" style="text-align: justify;">Protected</h2>
<ul style="text-align: justify;">
<li>The protected modifier is within the package and outside the package through child class.</li>
<li>It cannot be accessed from outside the package, if you do not make the child class.</li>
</ul>
<h3 id="sample-code-3" style="text-align: justify;">Sample Code</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">package pack;  <br/><br/>public class A{  <br/><br/>protected void msg(){<br/>System.out.println(&quot;Welcome to Wikitechy&quot;);<br/>}  <br/><br/>}  </code></pre> </div>
<h3 id="output-3" style="text-align: justify;">Output</h3>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4752" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier.png" alt="" width="883" height="187" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier.png 883w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-300x64.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-768x163.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-390x83.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-820x174.png 820w" sizes="(max-width: 883px) 100vw, 883px" /></p>
<h2 id="default" style="text-align: justify;">Default</h2>
<ul style="text-align: justify;">
<li>The default modifier is only within the package and it cannot be accessed from outside the package.</li>
<li>It will be the default, if you do not specify any access level.</li>
</ul>
<h3 id="sample-code-4" style="text-align: justify;">Sample Code</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">package pack;  <br/><br/>class A{  <br/><br/>  void msg(){System.out.println(&quot;Welcome to Wikitechy&quot;);}  <br/><br/>} </code></pre> </div>
<h2 id="output-4" style="text-align: justify;">Output</h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4752" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier.png" alt="" width="883" height="187" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier.png 883w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-300x64.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-768x163.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-390x83.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/access-modifier-820x174.png 820w" sizes="(max-width: 883px) 100vw, 883px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-are-the-cpp-access-modifiers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What are the advantages and disadvantages of C++ ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-are-the-advantages-and-disadvantages-of-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-are-the-advantages-and-disadvantages-of-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 05:37:48 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Advantages and Disadvantages of C Plus Plus Language]]></category>
		<category><![CDATA[Advantages and Disadvantages of C++]]></category>
		<category><![CDATA[Advantages and Disadvantages of C++ language]]></category>
		<category><![CDATA[Advantages and Disadvantages of C++ programming language]]></category>
		<category><![CDATA[advantages of c++ over c]]></category>
		<category><![CDATA[disadvantages of c++]]></category>
		<category><![CDATA[disadvantages of c++ programming language]]></category>
		<category><![CDATA[what are the advantages and disadvantages of array in c]]></category>
		<category><![CDATA[what are the advantages and disadvantages of c language]]></category>
		<category><![CDATA[what are the advantages and disadvantages of c section]]></category>
		<category><![CDATA[What are the advantages and disadvantages of C++]]></category>
		<category><![CDATA[what are the advantages and disadvantages of recursion in c]]></category>
		<category><![CDATA[what are the advantages of c++]]></category>
		<category><![CDATA[What are the advantages of C++ Programming Language?]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4747</guid>

					<description><![CDATA[C++ programming language is one of the oldest and most efficient language that still continues to dominate the realm of programming. For every beginner wants to know about the advantages and disadvantages of C++on the basis of which they can start their programming journey. Limitations and Benefits are the most important to know to predict [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">C++ programming language is one of the oldest and most efficient language that still continues to dominate the realm of programming.</li>
<li style="text-align: justify;">For every beginner wants to know about the advantages and disadvantages of C++on the basis of which they can start their programming journey.</li>
<li style="text-align: justify;">Limitations and Benefits are the most important to know to predict their next step.</li>
</ul>
<h2 id="advantages-of-c" style="text-align: justify;"><strong>Advantages of C++</strong></h2>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4748 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C.png" alt="" width="1193" height="892" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C.png 1193w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C-300x225.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C-1024x766.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C-768x574.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C-240x180.png 240w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C-390x292.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C-820x613.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/advantages-of-C-1180x882.png 1180w" sizes="(max-width: 1193px) 100vw, 1193px" /></p>
<h3 id="portability" style="text-align: justify;">Portability</h3>
<ul style="text-align: justify;">
<li>Portability or platform independence which allows the user to run the same program on different interfaces or operating system.</li>
<li>For programmer this feature proves to be of great convenience.</li>
<li>Suppose in Linux OS we write a program and for some reason switch to Windows OS, we would be able to run the same program in windows as well without any error.</li>
</ul>
<h3 id="object-oriented" style="text-align: justify;">Object-Oriented</h3>
<ul style="text-align: justify;">
<li>In C++ the feature of object-oriented programming which includes concepts like classes, polymorphism, inheritance, encapsulation and data abstraction that makes a program even more reliable and allow code reusability.</li>
</ul>
<h3 id="multi-paradigm" style="text-align: justify;">Multi-Paradigm</h3>
<ul style="text-align: justify;">
<li>It is a multi-paradigm programming language.</li>
<li>The term paradigm refers to the style of programming and includes procedure, logic and structure.</li>
<li>Generic, object-oriented and imperative are the three paradigms of C++.</li>
</ul>
<h3 id="memory-management" style="text-align: justify;">Memory Management</h3>
<ul style="text-align: justify;">
<li>C++ programmer gives the provision of total control over memory management.</li>
<li>An asset and a liability are the both increases the responsibility of the user to manage memory rather than it being managed by Garbage Collector.</li>
</ul>
<h3 id="compatibility-with-c" style="text-align: justify;">Compatibility with C</h3>
<ul style="text-align: justify;">
<li>Compare with C program, C++ is pretty much compatibility</li>
<li>Every error-free C program is a valid of C++ program, virtually.</li>
<li>Every program of C++ can run on a file with .cpp extension, depending on the compiler used.</li>
</ul>
<h3 id="low-level-manipulation" style="text-align: justify;">Low-Level Manipulation</h3>
<ul style="text-align: justify;">
<li>At certain level C++ allows low-level manipulation of data, which is a procedural language closely related to the machine language, C++ is closely associated with C.</li>
<li>Compiler and embedded systems are created with the help of C++.</li>
</ul>
<h3 id="large-community-support" style="text-align: justify;">Large Community Support</h3>
<ul style="text-align: justify;">
<li>C++ has a large community that supports it by providing online courses and both paid, unpaid and lectures.</li>
<li>Statistically speaking, in Stack Overflow and Git Hub C++ is the most used and followed tag.</li>
</ul>
<h3 id="scalability" style="text-align: justify;">Scalability</h3>
<ul style="text-align: justify;">
<li>Scalability refers to the ability of a program to scale, that means the C++ program is capable of running on a small scale as well as a large scale of data.</li>
</ul>
<h2 id="disadvantages-of-c" style="text-align: justify;"><strong>Disadvantages of C++</strong></h2>
<p style="text-align: center;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4749" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/disadvantages-of-C.png" alt="" width="1050" height="975" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/disadvantages-of-C.png 1050w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/disadvantages-of-C-300x279.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/disadvantages-of-C-1024x951.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/disadvantages-of-C-768x713.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/disadvantages-of-C-390x362.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/disadvantages-of-C-820x761.png 820w" sizes="(max-width: 1050px) 100vw, 1050px" /></p>
<h3 id="use-of-pointers" style="text-align: justify;">Use of pointers</h3>
<ul style="text-align: justify;">
<li>Pointers in C++ consumes a lot of memory and relatively difficult concept to grasp.</li>
<li>Misuse of pointers like wild pointers may cause the system to behave or crash anomalously.</li>
</ul>
<h3 id="absence-of-garbage-collector" style="text-align: justify;">Absence of garbage collector</h3>
<ul style="text-align: justify;">
<li>Using Dynamic Memory Allocation (DMA) C++ gives the user complete control of managing the computer memory.</li>
<li>It lacks the feature of a garbage collector to automatically filter out unnecessary data.</li>
</ul>
<h3 id="security-issues" style="text-align: justify;">Security Issues</h3>
<ul style="text-align: justify;">
<li>As compared to other programming languages object-oriented programming offers a lot of security to the data being handled that are not object-oriented, like C, certain security issues still exist due to the availability of pointers, friend functions and global variables.</li>
</ul>
<h3 id="absence-of-built-in-thread" style="text-align: justify;">Absence of built-in thread</h3>
<ul>
<li style="text-align: justify;">Threads is a relatively new concept in C++ which wasn’t initially there and it does not support any built-in threads.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-are-the-advantages-and-disadvantages-of-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Difference between Class and Structure</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/difference-between-class-and-structure/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/difference-between-class-and-structure/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Thu, 18 Aug 2022 05:17:56 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Difference between Class and Structure in C++]]></category>
		<category><![CDATA[difference between class and structure in java]]></category>
		<category><![CDATA[Difference between Classes and Structures]]></category>
		<category><![CDATA[Difference between Structure and Class]]></category>
		<category><![CDATA[difference between structure and class in c in tabular form]]></category>
		<category><![CDATA[Difference between Structure and Class in C++]]></category>
		<category><![CDATA[difference between structure and union]]></category>
		<category><![CDATA[similarities between class and structure in c]]></category>
		<category><![CDATA[structure in oops]]></category>
		<category><![CDATA[Structure vs class in C++]]></category>
		<category><![CDATA[Structures and Classes]]></category>
		<category><![CDATA[What is the difference between class and structure?]]></category>
		<category><![CDATA[what is the difference between struct and class in c mcq]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4743</guid>

					<description><![CDATA[                  Structure                        Class Structure is a collection of different types of data type Class is a group of common objects that share common properties and relationships. By default, structure member is public By default, class member is private Structure is value type so they are stored on stack Class is reference type [&#8230;]]]></description>
										<content:encoded><![CDATA[<table width="0">
<tbody>
<tr>
<td width="354"><strong> </strong><strong> </strong></p>
<p><strong>               Structure</strong></td>
<td width="336"><strong> </strong><strong> </strong></p>
<p><strong>                    Class</strong></td>
</tr>
<tr>
<td width="354">Structure is a <strong>collection of different types of data type</strong></td>
<td width="336">Class is a <strong>group of common objects that share common properties and relationships.</strong></td>
</tr>
<tr>
<td width="354">By default, <strong>structure member is public</strong></td>
<td width="336">By default,<strong> class member is private</strong></td>
</tr>
<tr>
<td width="354">Structure is <strong>value type</strong> so they are stored on stack</td>
<td width="336">Class is <strong>reference type</strong> so they are stored on heap</td>
</tr>
<tr>
<td width="354">It cannot be inherited</td>
<td width="336">It can be inherited</td>
</tr>
<tr>
<td width="354">Structure should be used when you want to use a small data structure</td>
<td width="336">Class is better choice for complex data structure</td>
</tr>
<tr>
<td width="354">Structure elements <strong>cannot be declared as protected</strong></td>
<td width="336">Class elements <strong>can be declared as protected</strong></td>
</tr>
<tr>
<td width="354">GC does not call finalize method for them because structure are not terminated</td>
<td width="336">GC does call finalize method for them because class are terminated</td>
</tr>
<tr>
<td width="354">Structure <strong>does not require constructor</strong></td>
<td width="336">Class <strong>does require constructor</strong></td>
</tr>
<tr>
<td width="354">The member variable of <strong>structure cannot be initialized directly</strong></td>
<td width="336">The member variable of <strong>class can be initialized directly</strong></td>
</tr>
<tr>
<td width="354">It can only have <strong>parameterized constructor</strong></td>
<td width="336">It can have all <strong>types of constructor and destructor</strong></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/difference-between-class-and-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Difference between C and C++</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/difference-between-c-and-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/difference-between-c-and-cpp/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Wed, 17 Aug 2022 12:34:59 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[difference between c and c plus plus]]></category>
		<category><![CDATA[difference between c and c sharp]]></category>
		<category><![CDATA[difference between c and c++]]></category>
		<category><![CDATA[difference between c and c++ and c#]]></category>
		<category><![CDATA[difference between c and c++ and java]]></category>
		<category><![CDATA[difference between c and c++ and java and python]]></category>
		<category><![CDATA[difference between c and c++ interview questions]]></category>
		<category><![CDATA[difference between c and c++ language]]></category>
		<category><![CDATA[difference between c and c++ with example program]]></category>
		<category><![CDATA[difference between c and java]]></category>
		<category><![CDATA[difference between c++ and python]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4739</guid>

					<description><![CDATA[C vs C++                           C                           C++ C programming language was developed by Dennis Ritchie C++ programming language was developed by Bjarne Stroustrup It is a structural programming language It is both object-oriented and structural programming language Data and functions are the free entries in C program language Data and functions are encapsulated [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2 id="c-vs-c">C vs C++</h2>
<table width="0">
<tbody>
<tr>
<td width="338"><strong> </strong></p>
<p><strong>                        C </strong></td>
<td width="338"><strong> </strong></p>
<p><strong>                        C++</strong></td>
</tr>
<tr>
<td width="338">C programming language was developed by <strong>Dennis Ritchie</strong></td>
<td width="338">C++ programming language was developed by <strong>Bjarne Stroustrup</strong></td>
</tr>
<tr>
<td width="338">It is a <strong>structural programming</strong> language</td>
<td width="338">It is both<strong> object-oriented and structural</strong> programming language</td>
</tr>
<tr>
<td width="338">Data and functions are the free entries in C program language</td>
<td width="338">Data and functions are encapsulated together in the form of a project in C++ program language.</p>
<p>&nbsp;</td>
</tr>
<tr>
<td width="338"><strong>Data can be accessed</strong> by the world. Therefore, C program does not support data hiding.</td>
<td width="338"><strong>Data cannot be accessed</strong> by the world. Therefore, C++ program support data hiding.</td>
</tr>
<tr>
<td width="338">It supports either <strong>function nor operator overloading.</strong></td>
<td width="338">It supports both <strong>functions and overloading</strong>.</td>
</tr>
<tr>
<td width="338">Functions cannot be implemented inside the structures in C program language</td>
<td width="338">Functions can be implemented inside the structures in C++ program language</td>
</tr>
<tr>
<td width="338">In C program language <strong>reference variables are not supported</strong></td>
<td width="338">In C++ program language <strong>reference variables are supported</strong></td>
</tr>
<tr>
<td width="338"><strong>Virtual and friend functions does not support</strong> in C program language</td>
<td width="338"><strong>Virtual and friend functions support</strong> in C++ program language</td>
</tr>
<tr>
<td width="338"><strong>Scanf() and printf()</strong> are mainly used for input/output in C program language</td>
<td width="338">Stream <strong>cin and cout</strong> are mainly used to perform input and output operations.</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/difference-between-c-and-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Print pyramid triangle in C++</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/print-pyramid-triangle-in-cpp/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/print-pyramid-triangle-in-cpp/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 00:20:02 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[area of a triangular pyramid]]></category>
		<category><![CDATA[Atos interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[Bosch India Software interview questions and answers]]></category>
		<category><![CDATA[c program to print patterns of numbers]]></category>
		<category><![CDATA[c program to print patterns of numbers and alphabets]]></category>
		<category><![CDATA[c program to print patterns of numbers and stars in a pyramid shape]]></category>
		<category><![CDATA[c program to print pyramid of numbers in reverse order]]></category>
		<category><![CDATA[c program to print pyramid pattern of numbers]]></category>
		<category><![CDATA[c++ pattern programs]]></category>
		<category><![CDATA[c++ program to print diamond of stars]]></category>
		<category><![CDATA[c++ program to print pyramid of numbers]]></category>
		<category><![CDATA[c++ program to print pyramid using *]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation interview questions and answers]]></category>
		<category><![CDATA[cstar programme]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Diamond pattern programs in c]]></category>
		<category><![CDATA[difficult number pattern programs in c]]></category>
		<category><![CDATA[double pyramid pattern in c]]></category>
		<category><![CDATA[eInfochips interview questions and answers]]></category>
		<category><![CDATA[Electronics Arts Inc interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Harman International interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Larsen & Toubro interview questions and answers]]></category>
		<category><![CDATA[letter pyramid c++]]></category>
		<category><![CDATA[Mathworks India Private Limited interview questions and answers]]></category>
		<category><![CDATA[Mavenir interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[nested loop c++ shapes]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[pascal triangle in c++ using array]]></category>
		<category><![CDATA[pascal's triangle formula]]></category>
		<category><![CDATA[pascal's triangle patterns]]></category>
		<category><![CDATA[pattern code]]></category>
		<category><![CDATA[pattern programs in c]]></category>
		<category><![CDATA[pattern programs in java]]></category>
		<category><![CDATA[patterns in c]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Philips Software Centre Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[print and pattern]]></category>
		<category><![CDATA[print pascal triangle c++]]></category>
		<category><![CDATA[print pattern]]></category>
		<category><![CDATA[programming patterns]]></category>
		<category><![CDATA[pyramid of numbers]]></category>
		<category><![CDATA[pyramid program in c]]></category>
		<category><![CDATA[pyramid program in c with explanation]]></category>
		<category><![CDATA[pyramid shape]]></category>
		<category><![CDATA[right triangle c++]]></category>
		<category><![CDATA[square based pyramid]]></category>
		<category><![CDATA[SRM Technologies interview questions and answers]]></category>
		<category><![CDATA[star pattern]]></category>
		<category><![CDATA[star pattern in c]]></category>
		<category><![CDATA[Symphony Teleca interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tecnotree interview questions and answers]]></category>
		<category><![CDATA[toughest pattern programs in c]]></category>
		<category><![CDATA[triangular pyramid]]></category>
		<category><![CDATA[volume of a square based pyramid]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<category><![CDATA[Wipro interview questions and answers]]></category>
		<category><![CDATA[Yash Technologies interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=406</guid>

					<description><![CDATA[Answer : To print pyramid triangle in C++, we have use two for loop...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="print-pyramid-triangle-in-c" class="color-pink" style="text-align: justify;">Print pyramid triangle in C++</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>To print pyramid <a href="https://www.wikitechy.com/tutorials/csharp/csharp-fibonacci-series" target="_blank" rel="noopener">triangle</a> in C++, we have use two for loop, the outer for loop and the inner for loop.</li>
<li>The outer for loop is responsible for rows and the inner for loop is responsible for column.</li>
<li>C++ programs to print different types of <a href="https://www.wikitechy.com/technology/c-program-to-print-patterns-of-numbers-and-stars/" target="_blank" rel="noopener">patterns using stars(*)</a>, numbers, and characters or alphabets.</li>
<li>This C++ program prints the full pyramid using stars(*).</li>
</ul>
<h2 id="sample-code-in-c" class="color-purple">Sample Code in C++</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;iostream&gt;<br/>using namespace std;<br/>   int main()<br/>{<br/>    int j, rows;<br/>       cout &lt;&lt;&quot;Enter number of rows: &quot;;<br/>    cin &gt;&gt; rows;<br/>       for(int i = 1, k = 0; i &lt;= rows; ++i, k = 0)<br/>    {<br/>        for(j = 1; j &lt;= rows-i; ++j)<br/>        {<br/>            cout &lt;&lt;&quot;  &quot;;<br/>        }<br/>        while(k != 2*i-1)<br/>        {<br/>            cout &lt;&lt; &quot;* &quot;;<br/>            ++k;<br/>        }<br/>        cout &lt;&lt; endl;<br/>    }    <br/>    return 0;<br/>}</code></pre> </div>
<h2 id="output" class="color-purple">Output</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">Enter number of rows : 7   <br/>            * <br/>          * * * <br/>        * * * * * <br/>      * * * * * * * <br/>    * * * * * * * * * <br/>  * * * * * * * * * * * <br/>* * * * * * * * * * * * * </code></pre> </div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/print-pyramid-triangle-in-cpp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
