Kolorwanie:
Status:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
#include <iostream>
#include <fstream>

using namespace std;

class K1{
  private:
    string w1;
    string *w2;
    double w3;
  public:
    friend class K2;
    K1():w1{"default"},w2{nullptr}, w3{0}{
    w2=new string;
    }
    K1(const string& w1val,const string& w2val, const double& w3val):w1{w1val},w2{nullptr},w3{w3val}{

      w2=new string;
      *w2= w2val;
    }
    K1(const K1& source):w1{source.w1},w3{source.w3}{
      w2=new string;
      *w2=*source.w2;
    }
    ~K1(){
      delete w2;
      }
    K1 &operator =(const K1& d){
      if(this==&d){
        return *this;
      }
      w2= new string;
      w1=d.w1;
     *w2=*d.w2;
      w3=d.w3;
      return *this;
    }
friend ostream &operator<<(ostream &out, const K1& d);
  };
  ostream &operator<<(ostream &out, const K1& d) {
      out<<d.w1<<"  "<<*d.w2<<"  "<<d.w3<<endl;
          return out;
          }


class K2{
  private:
    K1 ob1;
  public:
    K2():ob1{"default",nullptr,0}{
      

  }
  //   K2(const string& w1val,const string& w2val, const double& w3val):ob1{w1val, w2val, w3val}{
   //
  //  }
   ~K2(){
   }
  friend ostream &operator<<(ostream &out, const K2&d);
};
  ostream &operator<<(ostream &out, const K2&d){
    out<<d.ob1;
        return out;
        }






int main(int argc, char const *argv[]) {
  K2 ob1, ob2;

  // const K2 *wsk1 = new K2("kawa", "z mlekiem", 4.50)
  // const K2 ob3(*wsk1);
  // delete wsk1;
  // wsk1=0;
  // const K2* wsk2= new K2(ob3);
  // ob2=*wsk2;
  // cout<< ob1<<*wsk2;
  // delete wsk2;
  // wsk2=0;
  // cout<<ob2;
  // cout<<ob2-1.25;

  return 0;
}


Copyrights 2014-2019 © Wklejaj.pl Wszelkie prawa zastrzeżone.