USER'S CHOICE POST

Internet Download Manager free download for life time activated
Top 10 software you must have in your computer/laptop/tab with free download link

Earn upto Rs. 9,000 pm checking Emails. Join now! And get Rs. 99 Instantly!

ALL THE INFORMATION GIVEN IN THIS SITE IS ONLY FOR THE LEARNING PURPOSE. WE SHOULD ALWAYS USE THE GENUINE SOFTWARE! USE OF ANY INFORMATION GIVEN HERE IS SOLELY USERS' RESPONSIBILITY!


Sunday, 1 April 2012

Simple program to see the concept of class & object

Filled under:

Simple program to see the concept of class & object

program code:-


#include<iostream.h>
#include<conio.h>
class test
{
int n;
public:
void get(int a) //passed value of a=20 from t1.get(20);
{
n=a+1;
}
void show()
{
cout<<"n="<< n br="br" n="n" of="of" shows="shows" the="the" value="value"> }
};
void main()
{
test t1; // t1 object is created of test class
t1.get(20); // get func called by t1
t1.show(); // show func call by t1
getch();
}


output:=  21

Explanation:
Here we have created an object "t1" of class test.
"void get" and "void show" is two public functions in the class "test".
Now when t1.get(20); is called int a has been passed value 20 & thn added by 1 & stored in n.
Now t1.show is called which show the value of n by the command "cout"

so the value of n becomes 21.

Dont forget to join & share this with your friends!

2 comments:

  1. there is some statement missing in this program ... }.. u forgt to clos....

    ReplyDelete
  2. OH THANK YOU BIAKA..FOR HELPING US!
    ACTUALLY AT THE TIME OF PASTING HERE ITS JUST A MISS HANDLED..! WELL THANKS..KEEP VISITING!

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...


Try New Whatsapp+ latest for free with lots of new Emoticons :) , Latest Version
Download NOW