CONSTRUCTOR AND DESTRUCTOR
AIM:
A program to print student details using constructor and destructor
ALGORITHAM:
1. Start the process
2. Invoke the classes
3. Call the read() function
a. Get the inputs name ,roll number and address
4. Call the display() function
a. Display the name,roll number,and address of the student
5. Stop the process
PROGRAM
#include<iostream.h> #include<conio.h> class stu { private: char name[20],add[20]; int roll,zip; public: stu ( );//Constructor ~stu( );//Destructor void read( ); void disp( ); }; stu :: stu( ) { cout<<”This is Student Details”<<endl; } void stu :: read( ) { cout<<”Enter the student Name”; cin>>name; cout<<”Enter the student roll no “; cin>>roll; cout<<”Enter the student address”; cin>>add; cout<<”Enter the Zipcode”; cin>>zip; } void stu :: disp( ) { cout<<”Student Name :”<<name<<endl; cout<<”Roll no is :”<<roll<<endl; cout<<”Address is :”<<add<<endl; cout<<”Zipcode is :”<<zip; } stu : : ~stu( ) { cout<<”Student Detail is Closed”; } void main( ) { stu s; clrscr( ); s.read ( ); s.disp ( ); getch( ); }
Output:
Enter the student Name
James
Enter the student roll no
01
Enter the student address
Newyork
Enter the Zipcode
919108
Student Name : James
Roll no is : 01
Address is : Newyork
Zipcode is :919108
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
August 13th, 2011 at 12:55 pm
This nigga have fun, like a serial killer
December 14th, 2011 at 9:56 am
Very good programming.
January 24th, 2012 at 2:00 pm
thanks a lot! to you!!!!!
February 7th, 2012 at 4:00 pm
Romelia Rashed rihana I am in hospital wid AIDS……….. I cant live lik dis …..Help me i NEED u all…. 1 nite ….. otherwisw go to hell n die!!!