/* Default constructure
***********************/
#include<iostream>
using namespace std;
class practice
{
private:
int a,b;
public: //this is a public part of the class and constructure alway define in a public part
practice() //this is a method of making constructure
{
a=10;
b=490;
}
void display()
{
cout<<"the value of a:"<<a<<endl;
cout<<"the value of b:"<<b<<endl;
}
};
int main()
{
practice p; //when we make a object of a class then the constructure call automatically.
p.display();
}
No comments:
Post a Comment