Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Vector {
- double x,y;
- public:
- Vector(double,double);
- Vector();
- void print();
- double abs();
- };
- Vector::Vector(double x, double y) {
- this->x = x;
- this->y = y;
- }
- Vector::Vector() {
- cin >> x >> y;
- }
- void Vector::print() {
- cout << "(" << x << "," << y << ")";
- }
- double Vector::abs() {
- return sqrt(x*x+y*y);
- }
- class ColorVector:Vector{
- double x,y;
- char * szin;
- public:
- ColorVector(double,double,char *);
- void print();
- };
- ColorVector::ColorVector(double x,double y,char * szin):Vector(x,y){
- this->szin=szin;
- }
- void ColorVector::print(){
- cout<<"("<<x<<","<<y<<")["<<szin<<"]";
- }
- int main(int argc, char** argv) {
- /*Vector *v = new Vector();
- v->print();
- cout << v->abs();
- delete v;
- //Vector v;
- //v.print();
- //cout << v.abs();*/
- cout<< std::endl;
- ColorVector *k=new ColorVector(1,2,"piros");
- k->print();
- delete k;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement