<?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>constructor | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/constructor/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sun, 11 Dec 2022 09:24:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>What is the difference between new and malloc?</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/#comments</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Fri, 19 Aug 2011 09:29:06 +0000</pubDate>
				<category><![CDATA[C Questions & Answers]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[destructor]]></category>
		<category><![CDATA[operator ++]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[malloc]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[exception]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1648</guid>

					<description><![CDATA[<p>Here are the differences between new and malloc, Operator new constructs an object (calls constructor of object), malloc does not. Hence new invokes the constructor (and delete invokes the destructor)This is the most important difference. operator new is an operator, malloc is a function. operator new can be overloaded, malloc cannot be overloaded. operator new</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/">What is the difference between new and malloc?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Here are the differences between new and malloc,</p>
<ol>
<li>Operator new constructs an object (calls constructor of object), malloc does not. Hence new invokes the constructor (and delete invokes the destructor)This is the most important difference.</li>
<li>operator new is an operator, malloc is a function.</li>
<li>operator new can be overloaded, malloc cannot be overloaded.</li>
<li>operator new throws an exception if there is not enough memory, malloc returns a NULL.</li>
<li>operator new[] requires you to specify the number of objects to allocate, malloc requires you to specify the total number of bytes to allocate.</li>
<li>operator new/new[] must be matched with operator delete/delete[] to deallocate memory, malloc() must be matched with free() to deallocate memory.</li>
</ol>
<p><strong>Syntax of new is:</strong><br />
p_var = new type name;<br />
Where p_var is a previously declared pointer of type typename. And typename can be any basic data type.</p>
<p><strong>Example:</strong><br />
int  *p;<br />
p = new int;<br />
It allocates memory space for an integer variable.</p>
<p><strong>Syntax of malloc is:</strong><br />
p_var = (typename *)malloc(sizeof(typename));<br />
Where p_var is a previously declared pointer of type typename. And typename can be any basic data type.<br />
<strong></strong></p>
<p><strong>Example:<br />
</strong>int *p;<br />
p = (int *)malloc(sizeof(int));<br />
This statement &#8220;allocates&#8221; or &#8220;reserves&#8221; a block of memory for an integer from the heap. Then it places the address of the reserved block into the pointer variable (p, in this case).</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/">What is the difference between new and malloc?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to print student details using constructor and destructor</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-print-student-details-using-constructor-and-destructor/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-print-student-details-using-constructor-and-destructor/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 12 Mar 2010 18:22:49 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[c programs]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[destructor]]></category>
		<category><![CDATA[cpp class]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1046</guid>

					<description><![CDATA[<p>AIM: A program to print student details using a constructor and destructor. ALGORITHM: PROGRAM Output:</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-print-student-details-using-constructor-and-destructor/">C++ program to print student details using constructor and destructor</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>AIM: </strong></p>



<p>A program to print student details using a constructor and destructor.</p>



<p><strong>ALGORITHM:</strong></p>



<ol>
<li>Start the process</li>



<li>Invoke the classes</li>



<li>Call the read() function
<ul>
<li>Get the inputs name, roll number and address</li>
</ul>
</li>



<li>Call the display() function
<ul>
<li>Display the name, roll number, and address of the student</li>
</ul>
</li>



<li>Stop the process</li>
</ol>



<p><strong>PROGRAM</strong></p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">#include &lt;iostream>
using namespace std;

class student
{
	private: char name[20],add[20];
	  	int roll,zip;
	public: student ( ); //Constructor
		~student( ); //Destructor
		void read( );
		void disp( );			
};

student :: student( )
{
	cout&lt;&lt;"Student class constructor called."&lt;&lt;endl;
}

void student :: read( )
{
	cout&lt;&lt;"Enter the student Name: ";
	cin>>name;
	cout&lt;&lt;"Enter the student roll no: “;
	cin>>roll;
	cout&lt;&lt;"Enter the student address: ";
	cin>>add;
	cout&lt;&lt;"Enter the Zipcode: ";
	cin>>zip;
}

void student :: disp( )
{
	cout&lt;&lt;"Studet details"&lt;&lt;endl;
	cout&lt;&lt;"Student Name   :"&lt;&lt;name&lt;&lt;endl;
	cout&lt;&lt;"Roll no is     :"&lt;&lt;roll&lt;&lt;endl;
	cout&lt;&lt;"Address is     :"&lt;&lt;add&lt;&lt;endl;
	cout&lt;&lt;"Zipcode is     :"&lt;&lt;zip&lt;&lt;endl;
}

student :: ~student( )
{
	cout&lt;&lt;"Student class destructor called.";
}
 
int main( )
{
	student s;
	s.read();
	s.disp();
}</code></pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-code"><code lang="" class="">Student class constructor called.

Enter the student Name: Rajesh
Enter the student roll no: 1234
Enter the student address: Bangalore
Enter the Zipcode: 560001

Studet details
Student Name   :Rajesh
Roll no is     :1234
Address is     :Bangalore
Zipcode is     :560001

Student class destructor called.</code></pre>



<p></p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-print-student-details-using-constructor-and-destructor/">C++ program to print student details using constructor and destructor</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-print-student-details-using-constructor-and-destructor/feed/</wfw:commentRss>
			<slash:comments>34</slash:comments>
		
		
			</item>
	</channel>
</rss>
