Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Recenica {
- private:
- string * niza;
- int n;
- public:
- Recenica() {
- niza = new string[1];
- niza[0] = "default";
- n = 1;
- }
- Recenica(string * _niza, int _n) {
- n = _n;
- niza = new string[n];
- for(int i = 0; i < n; i++) {
- niza[i] = _niza[i];
- }
- }
- Recenica(const Recenica & tmp) {
- n = tmp.n;
- niza = new string[n];
- for(int i = 0; i < n; i++) {
- niza[i] = tmp.niza[i];
- }
- }
- Recenica & operator = (Recenica tmp) {
- n = tmp.n;
- niza = new string[n];
- for(int i = 0; i < n; i++) {
- niza[i] = tmp.niza[i];
- }
- return *this;
- }
- ~Recenica() {
- delete [] niza;
- }
- friend ostream & operator << (ostream & stream, Recenica & tmp);
- bool operator > (Recenica tmp) {
- if(n > tmp.n) {
- return true;
- }
- else {
- return false;
- }
- }
- Recenica & operator -= (string zbor) {
- string tmp_niza[n];
- for(int i = 0; i < n; i++) {
- tmp_niza[i] = niza[i];
- }
- n++;
- niza = new string[n];
- niza[0] = zbor;
- for(int i = 0; i < n - 1; i++) {
- niza[i + 1] = tmp_niza[i];
- }
- return *this;
- }
- Recenica & operator -- () {
- n--;
- return *this;
- }
- string & operator [] (int i) {
- return niza[i];
- }
- };
- ostream & operator << (ostream & stream, Recenica & tmp) {
- for(int i = 0; i < tmp.n; i++) {
- stream << tmp.niza[i] << " ";
- }
- stream << endl;
- return stream;
- }
- int main()
- {
- string zborovi[6]={"sakam","da","polozam","psp","vo","juni"}; Recenica r1=Recenica();
- Recenica r2=Recenica(zborovi,6); Recenica r3;
- r3=r2;
- cout<<r2;
- cout<<r3;
- r2-="Jas";
- cout<<r2;
- --r2;
- cout<<r2;
- cout<<(r2>r1);
- r1[0]="Nov";
- cout<<r1[0];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement