From c901708f28607aa46863e464dc6b5b30f1e8cc46 Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Tue, 24 May 2022 15:29:35 +0300 Subject: [PATCH 01/14] =?UTF-8?q?Create=20=D0=B3=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\320\263\320\263" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "\320\263\320\263" diff --git "a/\320\263\320\263" "b/\320\263\320\263" new file mode 100644 index 0000000..cd08dfc --- /dev/null +++ "b/\320\263\320\263" @@ -0,0 +1 @@ +тест From b4ad0cdffff027db7968ff592ee9067429db248c Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Tue, 24 May 2022 15:32:25 +0300 Subject: [PATCH 02/14] =?UTF-8?q?Delete=20=D0=B3=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\320\263\320\263" | 1 - 1 file changed, 1 deletion(-) delete mode 100644 "\320\263\320\263" diff --git "a/\320\263\320\263" "b/\320\263\320\263" deleted file mode 100644 index cd08dfc..0000000 --- "a/\320\263\320\263" +++ /dev/null @@ -1 +0,0 @@ -тест From e8ef8c8c00d2b79645c12cea6367f339b5915a4e Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Tue, 24 May 2022 15:51:38 +0300 Subject: [PATCH 03/14] Create animals.h --- animals.h | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 animals.h diff --git a/animals.h b/animals.h new file mode 100644 index 0000000..31e6175 --- /dev/null +++ b/animals.h @@ -0,0 +1,163 @@ +#pragma once + +#include +#include +#include + +class Animal { +private: + int Number_life; //years +public: + float weight; // kg + Animal() {}; + Animal(int Number_life) + { + Number_life = Numberl; + } + void setNumber_life(int Numberl) { Numberl = Number_life; } + int getNumber_life() { return Numberl; } + virtual string about() + { + stringctream str; + str << "Number of life = " << Numberl; + return str.str(); + } +}; + +class Mammal : public Animal { +private: + int Fertility; //number per year +public: + float pregnancyDuration; // days + Mammal() {}; + Mammal(int Fertility) + { + fert = Fertility; + } + void setFertility(int Fertility) { fert = Fertility; } + int getFertility() { return fert; } + virtual string about() + { + stringstream str; + str << "Fertility = " << fert; + return str.str(); + } +}; + +class Cat : public Mammal { + class Amphibia : public Animal { + private: + bool Virulence; //poisonous or not + public: + float vibrissaLength; // meters + Amphibia() {}; + Amphibia(bool Virulence) + { + toxic = Virulence; + } + bool getVirulence() { return toxic; } + void setVirulence(bool value) { toxic = value; } + virtual string about() + { + stringstream ss; + ss << "Virulence = " << toxic; + return ss.str(); + } + }; + + class Dog : public Mammal { + private: + string Сoat_color; //colour + public: + Dog() {}; + Dog(string Сoat_color) + { + сolor = Сoat_color; + } + string getСoat_color() { return сolor; } + void setСoat_color(string value) { сolor = value; } + virtual string about() + { + stringstream ss; + ss << "Сoat color = " << getСoat_color(); + return ss.str(); + } + }; + + class Сhihuahua : public Dog { + private: + int Barking_volume; //decibel + public: + Сhihuahua() {} + Сhihuahua(int Barking_volume) + { + Barking = Barking_volume; + } + int getBarking_volume() { return Barking; } + void setBarking_volume(int value) { Barking = value; } + virtual string about() + { + stringstream ss; + ss << "Barking volume = " << getSpeed() << "; " + << "Сoat color = " << getСoat_color() << endl; + return ss.str(); + } + } + + class Сamel : public Mammal { + private: + int Number_humps; //amount + public: + Сamel() {} + Сamel(int Number_humps) + { + Humpsk = Number_humps; + } + void setNumber_humps(int Humpsk) { Humpsk = Number_humps; } + float getNumber_humps() { return Humpsk; } + virtual string about() + { + stringstream str; + str << "Number of humps = " << Humpsk; + return str.str(); + } + }; + + class Snake : public Amphibia { + private: + bool Molt; //was or not + public: + Snake() {}; + Snake(bool Molt) + { + molt = Molt; + } + bool getMolt() { return molt; } + void setMolt(bool value) { molt = value; } + virtual string about() + { + stringstream ss; + ss << "Was there a molt = " << getMolt(); + return ss.str(); + } + }; + + class Turtle : public Amphibia { + private: + int Age; //years + public: + Turtle() {} + Turtle(int Age) + { + age = Age; + } + int getAge() { return age; } + void setAge(int age) { age = Age; } + virtual string about() + { + stringstream str; + str << "Age = " << age << "; " + << "Number of life = " << Numberl << endl; + return str.str(); + } + }; From 05941b02cf6cd02fbfbbbdd3f12cc564f7a42d6b Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Tue, 24 May 2022 15:52:27 +0300 Subject: [PATCH 04/14] Create animalss --- animalss | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 animalss diff --git a/animalss b/animalss new file mode 100644 index 0000000..214537b --- /dev/null +++ b/animalss @@ -0,0 +1,26 @@ +#include "animal.h" + +#include + using namespace std; + + int main() { + return 0; + } + int main() + { + Dog Lana("brown"); + Lana.setСoat_color("black"); + string aboutDog = Lana.about(); + cout << "Lana : " << aboutDog << endl; + + Snake Eve(true); + Eve.setMolt(false); + string MoltEve = Eve.about(); + cout << "Snake : " << MoltEve << endl; + + Turtle Sage(26, 40); + Sage.setAge(137); + Sage.setNumber_life(752); + string truth_about_Sage = Sage.about(); + cout << "Sage : " << truth_about_Sage << endl; + } From 7c458f78689a605bd52fa9131431eb25d946372b Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Tue, 24 May 2022 18:35:31 +0300 Subject: [PATCH 05/14] Delete animalss --- animalss | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 animalss diff --git a/animalss b/animalss deleted file mode 100644 index 214537b..0000000 --- a/animalss +++ /dev/null @@ -1,26 +0,0 @@ -#include "animal.h" - -#include - using namespace std; - - int main() { - return 0; - } - int main() - { - Dog Lana("brown"); - Lana.setСoat_color("black"); - string aboutDog = Lana.about(); - cout << "Lana : " << aboutDog << endl; - - Snake Eve(true); - Eve.setMolt(false); - string MoltEve = Eve.about(); - cout << "Snake : " << MoltEve << endl; - - Turtle Sage(26, 40); - Sage.setAge(137); - Sage.setNumber_life(752); - string truth_about_Sage = Sage.about(); - cout << "Sage : " << truth_about_Sage << endl; - } From 59da7b0a7f7e64031de892b3fe3f786251d8623f Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Tue, 24 May 2022 18:35:57 +0300 Subject: [PATCH 06/14] Delete animals.h --- animals.h | 163 ------------------------------------------------------ 1 file changed, 163 deletions(-) delete mode 100644 animals.h diff --git a/animals.h b/animals.h deleted file mode 100644 index 31e6175..0000000 --- a/animals.h +++ /dev/null @@ -1,163 +0,0 @@ -#pragma once - -#include -#include -#include - -class Animal { -private: - int Number_life; //years -public: - float weight; // kg - Animal() {}; - Animal(int Number_life) - { - Number_life = Numberl; - } - void setNumber_life(int Numberl) { Numberl = Number_life; } - int getNumber_life() { return Numberl; } - virtual string about() - { - stringctream str; - str << "Number of life = " << Numberl; - return str.str(); - } -}; - -class Mammal : public Animal { -private: - int Fertility; //number per year -public: - float pregnancyDuration; // days - Mammal() {}; - Mammal(int Fertility) - { - fert = Fertility; - } - void setFertility(int Fertility) { fert = Fertility; } - int getFertility() { return fert; } - virtual string about() - { - stringstream str; - str << "Fertility = " << fert; - return str.str(); - } -}; - -class Cat : public Mammal { - class Amphibia : public Animal { - private: - bool Virulence; //poisonous or not - public: - float vibrissaLength; // meters - Amphibia() {}; - Amphibia(bool Virulence) - { - toxic = Virulence; - } - bool getVirulence() { return toxic; } - void setVirulence(bool value) { toxic = value; } - virtual string about() - { - stringstream ss; - ss << "Virulence = " << toxic; - return ss.str(); - } - }; - - class Dog : public Mammal { - private: - string Сoat_color; //colour - public: - Dog() {}; - Dog(string Сoat_color) - { - сolor = Сoat_color; - } - string getСoat_color() { return сolor; } - void setСoat_color(string value) { сolor = value; } - virtual string about() - { - stringstream ss; - ss << "Сoat color = " << getСoat_color(); - return ss.str(); - } - }; - - class Сhihuahua : public Dog { - private: - int Barking_volume; //decibel - public: - Сhihuahua() {} - Сhihuahua(int Barking_volume) - { - Barking = Barking_volume; - } - int getBarking_volume() { return Barking; } - void setBarking_volume(int value) { Barking = value; } - virtual string about() - { - stringstream ss; - ss << "Barking volume = " << getSpeed() << "; " - << "Сoat color = " << getСoat_color() << endl; - return ss.str(); - } - } - - class Сamel : public Mammal { - private: - int Number_humps; //amount - public: - Сamel() {} - Сamel(int Number_humps) - { - Humpsk = Number_humps; - } - void setNumber_humps(int Humpsk) { Humpsk = Number_humps; } - float getNumber_humps() { return Humpsk; } - virtual string about() - { - stringstream str; - str << "Number of humps = " << Humpsk; - return str.str(); - } - }; - - class Snake : public Amphibia { - private: - bool Molt; //was or not - public: - Snake() {}; - Snake(bool Molt) - { - molt = Molt; - } - bool getMolt() { return molt; } - void setMolt(bool value) { molt = value; } - virtual string about() - { - stringstream ss; - ss << "Was there a molt = " << getMolt(); - return ss.str(); - } - }; - - class Turtle : public Amphibia { - private: - int Age; //years - public: - Turtle() {} - Turtle(int Age) - { - age = Age; - } - int getAge() { return age; } - void setAge(int age) { age = Age; } - virtual string about() - { - stringstream str; - str << "Age = " << age << "; " - << "Number of life = " << Numberl << endl; - return str.str(); - } - }; From b38973221df4b0a2435db88c284f06683cf1411e Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Sun, 29 May 2022 01:21:32 +0300 Subject: [PATCH 07/14] Create animalss --- animalss | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 animalss diff --git a/animalss b/animalss new file mode 100644 index 0000000..0097a91 --- /dev/null +++ b/animalss @@ -0,0 +1,27 @@ + +#include "animal.h" + +#include +using namespace std; + +int main() { + return 0; +} +int main() +{ + Dog Vlad("brown"); + Vlad.setСoat_color("black"); + string aboutDog = Vlad.about(); + cout << "Vlad : " << aboutDog << endl; + + Snake Gleb(true); + Gleb.setMolt(false); + string MoltGleb = Gleb.about(); + cout << "Snake : " << MoltGleb << endl; + + Frog Vasya(26, 40); + Vasya.setAge(137); + Vasya.setNumber_life(752); + string truth_about_Vasya = Vasya.about(); + cout << Vasya : " << truth_about_Vasya << endl; +} From 44a49846addc8fd5c409734b097d291979a7b661 Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Sun, 29 May 2022 01:23:18 +0300 Subject: [PATCH 08/14] Create animals1 --- animals1 | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 animals1 diff --git a/animals1 b/animals1 new file mode 100644 index 0000000..c3b0c7e --- /dev/null +++ b/animals1 @@ -0,0 +1,162 @@ +#pragma once + +#include +#include +#include + +class Animal { +private: + int Number_life; //years +public: + float weight; // kg + Animal(){}; + Animal(int Number_life) + { + Number_life = Numberl; + } + void setNumber_life(int Numberl) {Numberl = Number_life;} + int getNumber_life() {return Numberl;} + virtual string about() + { + stringctream str; + str << "Number of life = " << Numberl; + return str.str(); + } +}; + +class Mammal : public Animal { +private: + int Fertility; //number per year +public: + float pregnancyDuration; // days + Mammal(){}; + Mammal(int Fertility) + { + fert = Fertility; + } + void setFertility(int Fertility) {fert = Fertility;} + int getFertility() {return fert;} + virtual string about() + { + stringstream str; + str << "Fertility = " << fert; + return str.str(); + } +}; + +class Cat : public Mammal { +class Amphibia : public Animal { +private: + bool Virulence; //poisonous or not +public: + float vibrissaLength; // meters + Amphibia(){}; + Amphibia(bool Virulence) + { + toxic = Virulence; + } + bool getVirulence() {return toxic;} + void setVirulence(bool value) {toxic = value;} + virtual string about() + { + stringstream ss; + ss << "Virulence = " << toxic; + return ss.str(); + } +}; + +class Dog : public Mammal { +private: + string Сoat_color; //colour +public: + Dog(){}; + Dog(string Сoat_color) + { + сolor = Сoat_color; + } + string getСoat_color() {return сolor;} + void setСoat_color(string value) {сolor = value;} + virtual string about() + { + stringstream ss; + ss << "Сoat color = " << getСoat_color(); + return ss.str(); + } +}; + +class Husky : public Dog { +private: + int Barking_volume; //decibel +public: + Husky() {} + Husky(int Barking_volume) + { + Barking = Barking_volume; + } + int getBarking_volume() {return Barking;} + void setBarking_volume(int value) { Barking = value; } + virtual string about() + { + stringstream ss; + ss << "Barking volume = " << getSpeed() << "; " + << "Сoat color = " << getСoat_color() << endl; + return ss.str(); + } +} + +class Сamel : public Mammal { +private: + int Number_humps; //amount +public: + Сamel() {} + Сamel(int Number_humps) + { + Humpsk = Number_humps; + } + void setNumber_humps(int Humpsk) {Humpsk = Number_humps;} + float getNumber_humps() {return Humpsk;} + virtual string about() + { + stringstream str; + str << "Number of humps = " << Humpsk; + return str.str(); + } +}; + +class Snake : public Amphibia { +private: + bool Molt; //was or not +public: + Snake(){}; + Snake(bool Molt) + { + molt = Molt; + } + bool getMolt() {return molt;} + void setMolt(bool value) {molt = value;} + virtual string about() + { + stringstream ss; + ss << "Was there a molt = " << getMolt(); + return ss.str(); + } +}; + +class Frog : public Amphibia { +private: + int Age; //years +public: + Frog() {} + Frog(int Age) + { + age = Age; + } + int getAge() {return age;} + void setAge(int age) {age = Age;} + virtual string about() + { + stringstream str; + str << "Age = " << age << "; " + << "Number of life = " << Numberl << endl; + return str.str(); + } From 384b07d030380112015b52a1da96b8802da17df3 Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Sun, 29 May 2022 01:24:32 +0300 Subject: [PATCH 09/14] Update animalss --- animalss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/animalss b/animalss index 0097a91..daaca69 100644 --- a/animalss +++ b/animalss @@ -1,5 +1,5 @@ -#include "animal.h" +#include " animals1" #include using namespace std; From bdf2f5fa714936e914b73ddcb40695b752ecc5fe Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Tue, 14 Jun 2022 02:26:45 +0300 Subject: [PATCH 10/14] Create vectors212 --- vectors212 | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 vectors212 diff --git a/vectors212 b/vectors212 new file mode 100644 index 0000000..223fe30 --- /dev/null +++ b/vectors212 @@ -0,0 +1,92 @@ +#include +#include "vector.h" +#include + +using namespace std; + +ostream& operator <<(ostream& os, const vector3d& v) { + return os << "{ " << v[0] << ", " << v[1] << ", " << v[2] << " }"; +} +class Vector3d{ +public: + float data[3]; + Vector3d() { data[2]=data[1]=data[0]=0;} + Vector3d(float value) {data[2]=data[1]=data[0]=value;} + Vector3d(float x, float y, float z) {data[0]=x; data[1]=y; data[2]=z;} + float operator[](int idx) const { return data[idx];} + float& operator[](int idx) {return data[idx];} +Vector3d operator +(const Vector3d& other) const { + return Vector3d(data[0] + other[0], data[1]+other[1], data[2]+other[2]); +}; +Vector3d operator -(const Vector3d &other) { + return Vector3d(data[0]-other[0],data[1]-other[1], data[2]-other[2]); +}; +Vector3d operator *(const float value ) { + return Vector3d( data[0]*value, data[1]*value, data[2]*value); +}; +Vector3d operator /(const float value) { + return Vector3d(data[0]/value,data[1]/value,data[2]/value); +}; +Vector3d operator-() {return Vector3d(-data[0],-data[1],-data[2]); +}; +Vector3d operator !(){ + if ((data[0]==0) && (data[1]==0) && (data[2]==0)) + return Vector3d(data[0]==1,data[1]==1,data[2]==1); + else + return Vector3d(data[0]==0,data[1]==0,data[2]==0); +}; +}; + +int main(int argc, char** argv) { + vector3d v1, v2(12), v3(1, 3, 8); + v1[2] = 54; + //vector3d v4 = v1 + v2, v5 = v1 - v2, v6 = v1 * 0.5f; + //cout << "v4: " << v4 << endl << "v5: " << v5 << endl << "v6: " << v6 << endl; +ostream& operator <<(ostream& os, const Vector3d& v){ + return os << "{"<< v[0]<<","< Date: Tue, 14 Jun 2022 02:27:31 +0300 Subject: [PATCH 11/14] Delete vectors212 --- vectors212 | 92 ------------------------------------------------------ 1 file changed, 92 deletions(-) delete mode 100644 vectors212 diff --git a/vectors212 b/vectors212 deleted file mode 100644 index 223fe30..0000000 --- a/vectors212 +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include "vector.h" -#include - -using namespace std; - -ostream& operator <<(ostream& os, const vector3d& v) { - return os << "{ " << v[0] << ", " << v[1] << ", " << v[2] << " }"; -} -class Vector3d{ -public: - float data[3]; - Vector3d() { data[2]=data[1]=data[0]=0;} - Vector3d(float value) {data[2]=data[1]=data[0]=value;} - Vector3d(float x, float y, float z) {data[0]=x; data[1]=y; data[2]=z;} - float operator[](int idx) const { return data[idx];} - float& operator[](int idx) {return data[idx];} -Vector3d operator +(const Vector3d& other) const { - return Vector3d(data[0] + other[0], data[1]+other[1], data[2]+other[2]); -}; -Vector3d operator -(const Vector3d &other) { - return Vector3d(data[0]-other[0],data[1]-other[1], data[2]-other[2]); -}; -Vector3d operator *(const float value ) { - return Vector3d( data[0]*value, data[1]*value, data[2]*value); -}; -Vector3d operator /(const float value) { - return Vector3d(data[0]/value,data[1]/value,data[2]/value); -}; -Vector3d operator-() {return Vector3d(-data[0],-data[1],-data[2]); -}; -Vector3d operator !(){ - if ((data[0]==0) && (data[1]==0) && (data[2]==0)) - return Vector3d(data[0]==1,data[1]==1,data[2]==1); - else - return Vector3d(data[0]==0,data[1]==0,data[2]==0); -}; -}; - -int main(int argc, char** argv) { - vector3d v1, v2(12), v3(1, 3, 8); - v1[2] = 54; - //vector3d v4 = v1 + v2, v5 = v1 - v2, v6 = v1 * 0.5f; - //cout << "v4: " << v4 << endl << "v5: " << v5 << endl << "v6: " << v6 << endl; -ostream& operator <<(ostream& os, const Vector3d& v){ - return os << "{"<< v[0]<<","< Date: Tue, 14 Jun 2022 02:34:20 +0300 Subject: [PATCH 12/14] Create vectors212 --- vectors212 | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 vectors212 diff --git a/vectors212 b/vectors212 new file mode 100644 index 0000000..223fe30 --- /dev/null +++ b/vectors212 @@ -0,0 +1,92 @@ +#include +#include "vector.h" +#include + +using namespace std; + +ostream& operator <<(ostream& os, const vector3d& v) { + return os << "{ " << v[0] << ", " << v[1] << ", " << v[2] << " }"; +} +class Vector3d{ +public: + float data[3]; + Vector3d() { data[2]=data[1]=data[0]=0;} + Vector3d(float value) {data[2]=data[1]=data[0]=value;} + Vector3d(float x, float y, float z) {data[0]=x; data[1]=y; data[2]=z;} + float operator[](int idx) const { return data[idx];} + float& operator[](int idx) {return data[idx];} +Vector3d operator +(const Vector3d& other) const { + return Vector3d(data[0] + other[0], data[1]+other[1], data[2]+other[2]); +}; +Vector3d operator -(const Vector3d &other) { + return Vector3d(data[0]-other[0],data[1]-other[1], data[2]-other[2]); +}; +Vector3d operator *(const float value ) { + return Vector3d( data[0]*value, data[1]*value, data[2]*value); +}; +Vector3d operator /(const float value) { + return Vector3d(data[0]/value,data[1]/value,data[2]/value); +}; +Vector3d operator-() {return Vector3d(-data[0],-data[1],-data[2]); +}; +Vector3d operator !(){ + if ((data[0]==0) && (data[1]==0) && (data[2]==0)) + return Vector3d(data[0]==1,data[1]==1,data[2]==1); + else + return Vector3d(data[0]==0,data[1]==0,data[2]==0); +}; +}; + +int main(int argc, char** argv) { + vector3d v1, v2(12), v3(1, 3, 8); + v1[2] = 54; + //vector3d v4 = v1 + v2, v5 = v1 - v2, v6 = v1 * 0.5f; + //cout << "v4: " << v4 << endl << "v5: " << v5 << endl << "v6: " << v6 << endl; +ostream& operator <<(ostream& os, const Vector3d& v){ + return os << "{"<< v[0]<<","< Date: Tue, 14 Jun 2022 02:40:48 +0300 Subject: [PATCH 13/14] Create memhacks.cpp --- memhacks.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 memhacks.cpp diff --git a/memhacks.cpp b/memhacks.cpp new file mode 100644 index 0000000..99e8bbd --- /dev/null +++ b/memhacks.cpp @@ -0,0 +1,91 @@ +#include +#include +#include "memhacks.h" + +using namespace std; + +A::A() : a_s("It's a!") {} + +B::B() : b_s("It's b!") { + for (auto i = 0; i < sizeof(data) / sizeof(data[0]); i++) + for (auto i = 0; i < sizeof(data) / sizeof(data[0]); i++) { + data[i] = i * 2; + } +} + +/// +@@ -17,27 +21,52 @@ void printInternals(const B& b) { + const A* a = &b, * a2 = a + 1; + cout << "Address of b is 0x" << &b << ", address of b.a_s is 0x" << &b.a_s << ", address of b.b_s is 0x" << &b.b_s << endl; + cout << "Size of A is " << sizeof(A) << ", size of B is " << sizeof(B) << endl; + cout << "A string is '" << b.getAString() << "'" << endl; + cout << "B string is '" << b.getBString() << "'" << endl; + //cout << "B data: "; b.printData(cout); cout << endl; +} + +string A::getAString() const { + return *((const string*) ((const long*) (this) + 1)); +} + +/// +/// Извлекает значение из текущего объекта. +/// Подразумевается, что текущий объект на самом деле представлено классом . +/// +/// S +/// Значение B::b_s +std::string A::getBString() const { + // TODO +} +std::string A::getBString() const { return *((const string*) (this + 1)); } + +/// +/// Извлекает значения , и +/// из текущего объекта и выводит их в текстовом виде в указанный выходной поток +/// с помощью адресной арифметики. +/// Подразумевается, что текущий объект на самом деле представлено классом . +/// + +float A::getdataFloat(int i) const { return ((float*)(this + 2) - 4)[i]; } + +void A::printData(std::ostream& os) { + // TODO + os << getAString() + " " + getBString() + " {"; + for (int i = 0; i < 7; ++i) { + os << getdataFloat(i); + if (i != 6) os << ", "; + } + os << "}" << endl; +} + +string A::getA_s() const { return a_s; } +string B::getB_s() const { return b_s; } +string B::getDataStr() const { + stringstream ss; + ss << "{ "; + + for (int i = 0; i < 7; ++i) { + ss << data[i]; + if (i != 6) ss << "," << " "; + } + ss << '}'; + + return ss.str(); +} + +/// +@@ -46,12 +75,14 @@ void A::printData(std::ostream& os) { +/// с помощью виртуальных функций, предусмотренных в классе . +/// +void A::printData2(std::ostream& os) { + // TODO + os << getA_s() << " " << getB_s() << " " << getDataStr() << endl; +} + +int main() +{ + B b; + printInternals(b); + b.printData(cout); + b.printData2(cout); + return 0; +} From 62f9c04964c9a5f58a2c9f2b4308b03910c71bbb Mon Sep 17 00:00:00 2001 From: Sosika1377 <96603655+Sosika1377@users.noreply.github.com> Date: Tue, 14 Jun 2022 02:43:39 +0300 Subject: [PATCH 14/14] Create memhacks.h --- memhacks.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 memhacks.h diff --git a/memhacks.h b/memhacks.h new file mode 100644 index 0000000..a9876f0 --- /dev/null +++ b/memhacks.h @@ -0,0 +1,36 @@ +#pragma once +#include +#include +class B; +class A { + std::string a_s; + int foo; + + friend void printInternals(const B&); + virtual std::string getB_s() const { return " "; }; + virtual std::string getDataStr() const { return " "; }; + +public: + std::string getAString() const; + std::string getBString() const; + float getdataFloat(int i) const; + void printData(std::ostream& os); + void printData2(std::ostream& os); + + std::string getA_s() const; + + A(); +}; + +class B : public A { + class B : public A { + friend void printInternals(const B&); + +public: + std::string getB_s() const override; + std::string getDataStr() const override; + + B(); +}; + +void printInternals(const B& b);