Subscribe this Blog

Wikipedia

Search results

Notifications and New Posts!

Friday, July 31, 2020

Google Meet Session - 31st July 2020 C++ TY Mechanical (A and B)

C++ TY Mech AB
Friday, 31 July13:30 – 15:30
Weekly on Friday, until 30 Sep 2020
Join with Google Meet
https://meet.google.com/qaj-pyzn-zmy
Join by phone
Description:Dear Student Friends,Please join sharp at 13:30 today. I will admit/allow students up to 13:40.Those who will join late for them door will be closed means entry to the session will be denied. Please note. Because admitting late, creates disturbance to all.
  1. 10 minutes before
Organiser: Sachin Bhosale

With Kind Regards,

To know attendance : Click here

Today's Learning:

/*
destructor
Destructor destroys the created objects and makes free the memory location.
1. Destructor never take an argument.
2. Only one destructor is needed to destroy all objects created by constructor.
3. This special member function gets automatically called at the end of program
4. Last priority will be given to destructor as it destroys the created objects.

Note: Constructor and Destructor will not have any return type means they are not returning any value.
*/
#include<iostream.h>
#include<conio.h>
class sample
{
int no;
public:
sample()
{
cout<<"\n Please enter number=";
cin>>no;
cout<<"\n Value of Number="<<no;
}
~sample()
{
cout<<"\n Value of Number="<<no;
}
};
void main()
{
clrscr();
sample o1,o2,o3;
getch();
}

/*
Destructor destroys all created objects.
and helps to release memory of computer.
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class sample
{
private:
int No;
public:
sample()
{
cout<<"\n  I am in Constructor";
cout<<"\n  Please enter value of Number=";
cin>>No;
printf("\n Address of object=%u",&No);
}
~sample()
{
cout<<"\n  I am in Destructor";
printf("\n Address of object=%u",&No);
}
};

void main()
{
clrscr();
sample o1;
{
sample o2;
sample o3;
}
getch();
}

/*
parameterized constructor
*/
#include<iostream.h>
#include<conio.h>
class sample
{
int p,q;
public:
sample(int a,int b)
{
p=a;
q=b;
cout<<"\n p="<<p;
cout<<"\n q="<<q;
}
};
void main()
{
clrscr();
int a,b;
cout<<"\n Please enter a=";
cin>>a;
cout<<"\n Please enter b=";
cin>>b;
sample obj(a,b);
getch();
}


/*
function overloading
A C++ program to understand function overloading

Displaying side of rectangular box, Calculating area of rectangular box
and calculating volume of rectangular box by using single function fun()
In this case fun() is overloaded.
And in program we used function overloading.
*/
#include<iostream.h>
#include<conio.h>
class sample
{

public:
void fun(int);
void fun(int,int);
void fun(int,int,int);
};
void sample::fun(int l)
{
cout<<"\n fun() function will to display sides of rectangular box";
cout<<"\n Side of Rectangular Box="<<l;
}

void sample::fun(int l,int b)
{
cout<<"\n fun() function will calculate area of rectangular box";
cout<<"\n Area of Rectangular Box="<<l*b;
}

void sample::fun(int l,int b,int h)
{
cout<<"\n fun() function will calculate volume of rectangular box";
cout<<"\n Volume of Rectangular Box="<<l*b*h;
}

void main()
{
int l,b,h;
clrscr();
cout<<"\n Please enter l=";
cin>>l;
cout<<"\n Please enter b=";
cin>>b;
cout<<"\n Please enter h=";
cin>>h;
sample obj;
//first side of rectangular box is passed
obj.fun(l);
//second side of rectangular box is passed
obj.fun(b);
//third side of rectangular box is passed
obj.fun(h);
//area of rectangular box by considering first two sides
obj.fun(l,b);
//area of rectangular box by considering last two sides
obj.fun(b,h);
//area of rectangular box by considering first and last sides
obj.fun(l,h);
//Only one possibility can be considered as multiplication of three sides remains same
obj.fun(l,b,h);
getch();
}

Google Meet Session Video



No comments:

Post a Comment