Hi.. welcome to mysite in “We Are Knwledge”… in here you
want getting many IT knowledge…
I was writing many tutorial about IT knowledge,
from dekstop programming until web programming. And I too writing general knowledge
and little about design using “adobe photoshop”.
But, now I want writing IT knowledge about dekstop
programming using “C++”. And this time regarding the use of learning about “Classes”.
Ok.. let’s do read my article…
In the programming language C + + there is also a function
class. Class in C + + is a logical method for setting data and functions in the
same structure (not different). Class has its own declaration that uses the
keyword class, which is functionally the same as the keyword struct, but with
the inclusion of a function as a member of that class..
Syntax Class :
class name_of_class
{
permission_label_1:
member_number_1;
permission_label_2:
member_ number _2;
....
....
}
Name_of_object;
Logic ::
name_of_class
>> name from the class, you can have anything else
permission_label_1
>> This
statement can be either on the declaration of the function or data (the
contents of the function)
member_number_1;
>> contents of name_of_object
Name_of_object;
>> may include one or more valid object identifier.
• Private
>> class members can only be accessed from other
members of the same class (instead of a different class) or from the class
"friend".
• Protected
>>which is the opposite of provate members can be
accessed from the members of the same class or a class friend, and also members
of the class of derivatives (derived).
• Public
>>members can be accessed from any class or
combination of private and proteced.
Example 1:
You can copy thiscoding and paste in your compiller..
#include <iostream.h>
class CRectangle
{
int g, h;
public:
void set_values
(int,int);
int area (void)
{return (g * h);}
};
void CRectangle::set_values (int m, int l)
{
g = m;
h = l;
}
To result ::
value1 == 10
Value2 ==20
Ok.. just it,…
I hope you like with my article…
Don’t forget to came back to my site…
Thanks visitors and readers…
See you later
No comments:
Post a Comment