DreamsCoder.com

We Code your Dreams
home > cpp programs

Why C++ used in Clipper?



Label - cpp





What does extern mean in a function declaration?



Label - cpp





Friend Function Demonstration in C++



#include
#include

class student
{
	int roll_no;
	char name[20],address[40];
	
	public:
		friend void getdata(student,course);
//Friend function declaration

};


class course
{
	int c_id,duration;
	char c_name[20]

	public:
		friend void getdata(student,course);
//Friend function declaration
		
};

void getdata(student s,course c)
{
	cout<<"Enter roll no";
	cin>>s.roll_no;
	cout<<"Enter name";
	cin>>s.name;
	cout<<"Enter address";
	cin>>s.address;
	cout<<"Enter course id";
	cin>>c.c_id;
	cout<<"Enter course name";
	cin>>c.c_name;
}	


void main()
{
	student s1;
	course c1;
	getdata(s1,c1);
	getch();
}

Label - cpp





Virtual Destructor in C++



#include iostream.h
class Base
{
   	public:
      	Base(){ cout<<"Constructing Base";}
      	
	
	virtual ~Base(){ cout<<"Destroying Base";}
};

class Derive: public Base
{
        public:
       	Derive(){ cout<<"Constructing Derive";}
       	
       	~Derive(){ cout<<"Destroying Derive";}
 };

void main()
{
    	Base *basePtr = new Derive();
        
        delete basePtr;
}
____________________________________
Output
____________________________________

Constructing Base  
Constructing Derive 
Destroying Derive
Destroying Base

Label - cpp





Vector Demonstration Program in C++



Label - cpp





next page >






Privacy Policy
Copyright © 2018 by DreamsCoder. All Rights Reserved.
DreamsCoder Google Plus DreamsCoder Facebook



Latest Technology,Tricks and Tips