c++ class names
1 отговора
64 прегледа
c++ class names
zdr na vsichki.niakoi sblaskval li se s problema za ime na class.
za primer class name Rectangle(ima i mnogo drugi).
ako izpolzvate implementation sled scope se poiaviavat clas functions, no kato se opitate v main() ne se poiaviavat.no programata raboti excellent.
tuka tazi malka programa demonstrira tova:
------------------------------
//-----------------------
#include<iostream>
using namespace std;
class Rectangle
{
int a;//private member
public:
Rectangle()
{}//default construct
void show() const;//show data a
int get();//get from user data
};
//-----------------------
void Rectangle::show() const//scope works
{
cout<<"\n\tThe variable a is : "<<a<<endl;
}
//---------------------------------
int Rectangle::get()//scope works
{
cout<<"\n\tEnter data for a : ";cin>>a;
return a;
}
//-----------------------------------------
int main()
{
Rectangle obj;//initialize object obj from Rectangle
obj.get();//list s functions ne se poiaviava kato pichete obj.
obj.show();//list s functions ne se poiaviava kato pichete obj.
return 0;
}
--------------------------
compilers:ms visual 6.0,Bloodshed Dev C++
------------------
--------------------
tova koeto otkrix e che tova ime e buid-in i nosi tri parametara of type int
ako znaete neshto pichete
za primer class name Rectangle(ima i mnogo drugi).
ako izpolzvate implementation sled scope se poiaviavat clas functions, no kato se opitate v main() ne se poiaviavat.no programata raboti excellent.
tuka tazi malka programa demonstrira tova:
------------------------------
//-----------------------
#include<iostream>
using namespace std;
class Rectangle
{
int a;//private member
public:
Rectangle()
{}//default construct
void show() const;//show data a
int get();//get from user data
};
//-----------------------
void Rectangle::show() const//scope works
{
cout<<"\n\tThe variable a is : "<<a<<endl;
}
//---------------------------------
int Rectangle::get()//scope works
{
cout<<"\n\tEnter data for a : ";cin>>a;
return a;
}
//-----------------------------------------
int main()
{
Rectangle obj;//initialize object obj from Rectangle
obj.get();//list s functions ne se poiaviava kato pichete obj.
obj.show();//list s functions ne se poiaviava kato pichete obj.
return 0;
}
--------------------------
compilers:ms visual 6.0,Bloodshed Dev C++
------------------
--------------------
tova koeto otkrix e che tova ime e buid-in i nosi tri parametara of type int
ako znaete neshto pichete
t.e. problema e w redaktora
taka li da razbirame?
T.e. kato pishesh obj. i ne se pojawjawa avotmatichno listbox sus member-ite na klasa, taka li e?
T.e. kato pishesh obj. i ne se pojawjawa avotmatichno listbox sus member-ite na klasa, taka li e?