Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <cstring>
- #include "stdio.h"
- #include <conio.h>
- using namespace std;
- class tekst {
- char *p;
- public:
- tekst() {
- p = new char[1];
- }
- void assign(char *t) {
- strcpy(p, t);
- }
- tekst(char *t) {
- p = t;
- }
- void operator=(tekst a) {
- strcpy(p, a.p);
- }
- void print() {
- cout << p << endl; //użyć printf bo cout ssie
- }
- void operator!() {
- cout << this->p << endl; //tu to samo
- }
- tekst operator+(tekst &source) {
- char *temporary;
- int expectedSize = strlen(source.p) + strlen(p) + 1;
- temporary = new char[expectedSize];
- strcpy(temporary, p);
- strcat(temporary, source.p);
- p = new char[expectedSize];
- strcpy(p, temporary);
- delete[]temporary;
- return this->p;
- }
- };
- int main()
- {
- tekst a, b, c;
- b.assign("Tekscior"); //tu może wywali błąd ale podobno jest ładnie więc co sie bede kłócił
- b.print();
- a = b;
- !a;
- _getch();
- a.assign("Tekst");
- !a;
- a + b;
- !b; !a;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement