Class & object in c++

Class & object in c++

Class & object in c++
Ganesh
Tuesday 28 February 2017
Class & Object:- เค•िเคธी เคญी program เคฎें เค•เคˆ function เคคเคฅा เคตिเคญिเคจ्เคจ เคช्เคฐเค•ाเคฐ เค•े data type เคฎौเคœूเคฆ เคนोเคคे เคนै,
Similar data type เคคเคฅा member function เค•ा group class เค•เคนเคฒाเคคी เคนै। เคเค• class เคธเคฎाเคจ เคช्เคฐเค•ाเคฐ เค•े object เค•ा เคธเคฎूเคน เคนै।

Object เค•िเคธी เคญी class เค•े variable เค•ी เคคเคฐเคน เค•ाเคฎ เค•เคฐเคคे เคนै เคคเคฅा เคเค• class เค•े เคฒिเค เค•เคˆ เคธाเคฐे object defined เค•िเค เคœा เคธเค•เคคे เคนै।
Class เค•ा เคเค• name เคนोเคคा เคนै เคœो user dependent เคนोเคคा เคนै।

Class define เค•เคฐเคจे เค•े เคฒिเค:-
Class<class name>
{
---------//member function, data type
---------
}

Class เคฎें object define เค•เคฐเคจे เค•े เคฒिเค:-
<class name> <object name>;

Object เค•ा name เคญी user dependent เคนोเคคा เคนै।
เค•िเคธी เคญी class เค•े function เค•ो access เค•เคฐเคจे เค•े เคฒिเค object เค•ा เค‡เคธ्เคคेเคฎाเคฒ เคนोเคคा เคนै।

<object name>.<function name>;

Example class & object:-

#include<iostream.h>
class add            //define class
{
int a, b, c;
void sum()
{
Cout<<"enter the no.";
Cin>>a>>b;
c=a+b;
Cout<<c;
}
}
void main()
{
add a1;         // object defind in class
a1.sum();
}