<?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>virtual destructor in c++ - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/virtual-destructor-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/virtual-destructor-in-c/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Thu, 18 Aug 2022 12:31:25 +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>virtual destructor in c++ - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/virtual-destructor-in-c/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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 fetchpriority="high" 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>Find the wrong statement about Abstract Class ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/find-the-wrong-statement-about-abstract-class/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/find-the-wrong-statement-about-abstract-class/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Mon, 12 Jul 2021 22:54:00 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[abstract class in c++]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></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++ abstract class]]></category>
		<category><![CDATA[c++ abstract class constructor]]></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[Dell International Services India Pvt Ltd interview questions and answers]]></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[interface and abstract class in c++]]></category>
		<category><![CDATA[interface is partial abstract class true or false]]></category>
		<category><![CDATA[Larsen & Toubro interview questions and answers]]></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[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Philips Software Centre Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[pure virtual class in c++]]></category>
		<category><![CDATA[pure virtual function in c++]]></category>
		<category><![CDATA[Sapient Technical and HR Interview Questions]]></category>
		<category><![CDATA[SRM Technologies interview questions and answers]]></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[use of abstract class in c++]]></category>
		<category><![CDATA[use of virtual function in c++]]></category>
		<category><![CDATA[uses of abstract class in c++]]></category>
		<category><![CDATA[virtual base class in c++]]></category>
		<category><![CDATA[virtual destructor in c++]]></category>
		<category><![CDATA[Virtual Function in C++]]></category>
		<category><![CDATA[we can declare abstract method outside of abstract class mcq]]></category>
		<category><![CDATA[we can declare abstract method outside of abstract class true or false]]></category>
		<category><![CDATA[which of the following is true about abstract classes]]></category>
		<category><![CDATA[which of the following is used to make an abstract class mcq]]></category>
		<category><![CDATA[which of the following statement is false about abstract classes]]></category>
		<category><![CDATA[which statement is incorrect with respect to abstract class]]></category>
		<category><![CDATA[which statement is incorrect with respect to abstract class in c++]]></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=386</guid>

					<description><![CDATA[Answer : B. We can’t create pointers to an abstract class]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h3 id="find-the-wrong-statement-about-abstract-class" class="color-pink" style="text-align: justify;">Find the wrong statement about Abstract Class ?</h3>
<div class="row" style="text-align: justify;">
<div class="col-sm-6">
<p>A. We can’t create its objects</p>
</div>
<div class="col-sm-6">
<p>B. We can’t create pointers to an abstract class</p>
</div>
<div class="col-sm-6">
<p>C. It contains at least one pure virtual function</p>
</div>
<div class="col-sm-6">
<p>D. We can create references to an abstract class</p>
</div>
</div>
<h3 id="answer-b-we-cant-create-pointers-to-an-abstract-class" style="text-align: justify;"><b>Answer : </b>B. We can’t create pointers to an abstract class</h3>
</div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="explanation">Explanation :</h2>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Abstract Class is a class which contains atleast one Pure Virtual function.</li>
<li>An abstract class is a class that is designed to be specifically used as a base class.</li>
<li>It is used to provide an Interface for its sub classes.</li>
<li>Classes inheriting an Abstract Class must provide definition to the pure virtual function, otherwise they will also become abstract class.</li>
<li>You declare a pure virtual function by using a <b>pure specifier (= 0)</b> in the declaration of a virtual member function in the class declaration.</li>
</ul>
</div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="example" class="color-green">Example</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">class AB {<br/>public:<br/>  virtual void f() = 0;<br/>};</code></pre> </div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/find-the-wrong-statement-about-abstract-class/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
