Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // DynString.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stdio.h>
- #include <string>
- #include <conio.h>
- #include <iostream>
- using namespace std;
- class DynString
- {
- private:
- unsigned int _rozmiartekstu;
- int _rozmiartablicy;
- string napis;
- public:
- DynString(string _napis){
- napis=_napis;
- }
- unsigned int size(){
- _rozmiartekstu=napis.size();
- return _rozmiartekstu;
- }
- string cstr(){return napis;}
- string add(string _napis){
- napis=napis+_napis;
- return napis;
- }
- //bool set(int indeks , char znak){
- //return true;
- //}
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- DynString napis("Napis Testowy");
- printf("Napis : %s\n",napis.cstr());
- printf("Znakow : %u\n",napis.size());
- DynString kopia(napis);
- printf("Kopia : %s\n",kopia.cstr());
- printf("Znakow : %u\n",kopia.size());
- kopia.add("_Dodany Fragment.");
- printf("Napis org : %s\n",napis.cstr());
- printf("Znakow : %u\n",napis.size());
- printf("Kopia Add : %s\n",kopia.cstr());
- printf("Znakow : %u\n",kopia.size());
- DynString * nowy = new DynString("NAPIS TESTOWY ");
- nowy->add("DRUGI.");
- DynString kolejny(*nowy);
- delete nowy;
- printf("Nowy : %s\n",kolejny.cstr());
- printf("Znakow : %u\n",kolejny.size());
- printf("\nKoniec.");
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement