Biologie | Chimie | Didactica | Fizica | Geografie | Informatica | |
Istorie | Literatura | Matematica | Psihologie |
E5.1, E5.2, E5.3
#include <iostream.h>
class polinom
virtual ~polinom()
//cout << 'Destructor polinom' << endl;
}
int GetDegree() const
void SetDegree(int v)
int GetErr()const
void SetErr()
void* GetCoef() const
void SetCoef(void* c)
virtual void print()
virtual polinom& sum(const polinom &pol)=0;
//virtual polinom& prod(const polinom &pol)=0;
//virtual polinom& powr(int k)=0;
class lpolinom:public polinom
lpolinom(int d, long *c)
lpolinom(const lpolinom &pol)// constr. copiere
}
~lpolinom()
//cout << 'Destructor lpolinom' << endl;
}
polinom& sum(const polinom& pol);
void print();
void lpolinom::print()
polinom& lpolinom::sum(const polinom& pol)
else
void main ()
long cp2[] = ;
lpolinom p1(2,cp1);
lpolinom p2(3, cp2);
polinom &rez = p1.sum(p2);
rez.print();
delete (lpolinom*)&rez;
E5.4, E5.5
#include <iostream.h>
#include <stdlib.h>
class CPoint
CPoint(int d)
CPoint(int d, double *p)
CPoint(CPoint &r)
virtual ~CPoint()
}
double GetCoord(int pos)
void SetCoord(int pos, double v)
void Compare(CPoint p)
if (i>=dim)
cout <<'Punctele sunt identicen';
}
}
virtual void Draw()
class CPoint2d:public CPoint{
public:
CPoint2d():CPoint(2)
CPoint2d(double x, double y):CPoint(2)
CPoint2d(double *p):CPoint(2,p)
~CPoint2d()
void Draw()
class CPoint3d:public CPoint{
public:
CPoint3d():CPoint(3)
CPoint3d(double x, double y, double z):CPoint(3)
CPoint3d(double *p):CPoint(3,p)
~CPoint3d()
void Draw()
void main();
CPoint *p11 = new CPoint(4, coord);
coord[0] = 7;
CPoint *p12 = new CPoint(4, coord);
p12->Compare(*p11);
delete p11;
delete p12;
int x;
cin >> x;
/* Folosirea clasei derivate CPoint2d */
CPoint *p2 = new CPoint2d(4,5);
p2->Draw();
delete p2;
/* Folosirea clasei derivate CPoint3d */
CPoint *p3 = new CPoint3d(6,7,8);
p3->Draw();
delete p3;
/* Constructie de forme in diferite spatii */
int space;
CPoint *p = NULL;
for (;;)
}
Politica de confidentialitate |
Copyright © 2024 - Toate drepturile rezervate