Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Пример. Класс с вложенным конструктором
- #include<iostream>
- using namespace std;
- class Cls01
- {
- int *a;
- double *b;
- public:
- Cls01 (int p1, double p2)
- {
- a=new int (p1);
- b=new double (p2);
- }
- ~Cls01()
- {
- delete a; cout<<"Delete a"<<endl;
- delete b; cout<<"Delete b"<<endl;
- }
- void out_ab()
- {
- cout<<"a="<<*a<<"b="<<*b<<endl;
- }
- };
- class Cls02
- {
- Cls01 x,y;
- public:
- Cls02 (int, double, int, double);
- void out_xy()
- {
- x.out_ab();
- y.out_ab();
- }
- };
- Cls02::Cls02 (int l1, double l2, int l3, double l4): x (l1, l2), y (l3,l4)
- {
- }
- void main()
- {
- Cls02 s(10, 1.2, 20, 2.5);
- s.out_xy();
- }
Add Comment
Please, Sign In to add comment