FPoint(int xl, int yl, double wl):p(xl, yl), w(wl){}; void show()
{
cout«"koordinata x=" <
}
private:
Point p; double w;
};
int main()
{
cout«"fizik nuqta" «endl;
FPoint X(l, 2, 5.5);
X.show();
15.2.Ko‘plikdagi vorislik
Ko‘plik vorislik ta’rifi. Ko‘plik vorislik deb sinf ta’rifida bir necha sinf asos sinf sifatida ko‘rsatish imkoniga aytiladi.
Masalan: class Basisl {int a, b; public:
Basisl(int x, inty){a = x; b=y;}
};
class Basis2 {int c; char*s; public:
Basis2(int x, char*y){c=x; b = new' char[strlen(y) + l];} ~Basis2(){delete[]s;}
};
class Inherit:public Basisl, public Basis2
{int sum;
public:
Inherit(int x, int y, int z, char*d, int k):Basisl(x, y), Basis2(z, d) {sum = k;}
};
Quyidagi dasturda computer sinfini yaratish uchun, computer_screen va mother_board asos sinflaridan foydalaniladi:
#include < iostream >
#include
using namespace std; class computer_screen
{
public:
computer_screen(string, long, int, int);
void show_screen(void);
private:
string type;
Do'stlaringiz bilan baham: |