Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class K1 {
- string* p1;
- public:
- K1();
- K1(const K1&);
- K1& operator=(const K1&);
- void setStrings(const string& s1, const string& s2);
- };
- class K2 {
- K1 p1;
- double p2;
- public:
- K2() {};
- K2(const string& s1, const string& s2, double p);
- K2(const K2&);
- K2& operator=(const K2&);
- };
- K1::K1() {
- p1 = new string[2];
- }
- K1::K1(const K1& other) {
- this->operator=(other);
- }
- K1& K1::operator=(const K1& other) {
- this->p1 = other.p1;
- }
- void K1::setStrings(const string& s1, const string& s2) {
- p1[0] = s1;
- p1[1] = s2;
- }
- K2::K2(const string& s1, const string& s2, double p) {
- this->p1.setStrings(s1, s2);
- this->p2 = p;
- }
- K2::K2(const K2& other) {
- this->operator=(other);
- }
- K2& K2::operator=(const K2& other) {
- this->p1 = other.p1;
- this->p2 = other.p2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement