<?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 functions | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/virtual-functions/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 13 Mar 2010 17:59:23 +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>C++ program to illestrate virtual functions</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-illestrate-virtual-functions/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-illestrate-virtual-functions/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sat, 13 Mar 2010 17:59:23 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[virtual functions]]></category>
		<category><![CDATA[c++ virtual]]></category>
		<category><![CDATA[derived class]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[array of members]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1066</guid>

					<description><![CDATA[<p>AIM A program to access the member of the derived class objects through an array of members. In this program, both the base class and the derived class member functions are preceded by the keyword ALGORITHM 1. Start the process 2. Invoke the class with pointer 3. Assign ptr[0]</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-illestrate-virtual-functions/">C++ program to illestrate virtual functions</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>AIM</strong><br />
	A program to access the member of the derived class objects through an array of members. In this program, both the base class and the derived class member functions are preceded by the keyword</p>
<p><strong>ALGORITHM</strong></p>
<p>1.	Start the process<br />
2.	Invoke the class with pointer<br />
3.	Assign ptr[0] <- &objb;
i.	Assign ptr[1] <- &objc;
4.	Ptr(0)points the getdata()
a.	Get the values of x and y
5.	Ptr(1) points to the getdata()
a.	Get the roll no and name of the student
6.	Ptr(0) and ptr(1) are points to the display()
a.	Print the values
7.	Stop the process

<strong>PROGRAM</strong></p>
<pre lang="cpp">
#include<iostream.h>
#include<conio.h>
			
	class base
	{
		private: int x;
			float y;
		public:  
			virtual void getdata( );
			virtual void display( );
	};
	class devb: public base
	{
		private: int roll;
			char name[20];
		public:  virtual void getdata( );
			virtual void display( );
	};
	class devc : public  base
	{
		private: float height;
			float weight;
		public : virtual void getdata( );
			 virtual void display( );
	}:
	void base :: getdata( )
	{
		cout<<” Enter any Integer”;
		cin>>x;
		cout<<”Enter a real no”;
		cin>>y;
	}
	void base ::display( )
	{
		cout<<”The no X=”<<x<<”Y=”<<y<<endl;
	}
	void devb :: display( )
	{
		cout<<”Roll of the Student is:”<<roll<<endl;
		cout<<” Name of the Student is: “<<name<<endl;
	}
	void devb :: getdata( )
	{
		cout<<”Enter the Roll of  the Student:”;
		cin>>roll;
		cout<<”Enter Name of Student :”;
		cin>>name;
	}
	void devc :: getdata( )
	{
		cout<<”Enter height and weight”;
		cin>>height>>weight;
	}
	void devc :: display( )
	{
		cout<<”Height :”<<height<<endl;
		cout<<”Weight :”<<weight<<endl;
	}
	void main( )
	{
		base *ptr[3];
		devb objb;
		devc objc;
		clrscr( );
		ptr[0] = &objb;
		ptr[1] = &objc;
		ptr[0] ->getdata( );
		ptr[1] -> getdata( );
		ptr[1] -> display( );
		ptr[1] -> display( );
		getch ( );
  	}
</pre>
<p><strong>OUTPUT</strong></p>
<p>Enter the Roll of  the Student: 101<br />
Enter Name of Student : salah<br />
height and weight 170 72</p>
<p>Roll of  the Student is:101<br />
Name of  the Student is:salah<br />
Height :170<br />
Weight :72</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-illestrate-virtual-functions/">C++ program to illestrate virtual functions</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-illestrate-virtual-functions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
