Advertisement
rowers

notka

Feb 10th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  7.  
  8. class Notatka {
  9.     protected:
  10.         char *m_Tekst;
  11.        
  12.     public:
  13.         Notatka(char *tekst)
  14.         {
  15.             m_Tekst = new char[strlen(tekst)+1];
  16.             strcpy(m_Tekst, tekst);
  17.         }
  18.        
  19.         Notatka(const Notatka& notka) //Notatka note1; Notatka note2(note1);
  20.         {
  21.             m_Tekst = new char[strlen(notka.m_Tekst)+1];
  22.             strcpy(m_Tekst, notka.m_Tekst);
  23.         }
  24.  
  25.  
  26.         Notatka &operator =(const Notatka& notka) //Notatka note1; Notatka note2=note1;
  27.         {
  28.             if(m_Tekst)
  29.                 delete [] m_Tekst;
  30.  
  31.             m_Tekst = new char[strlen(notka.m_Tekst)+1];
  32.             strcpy(m_Tekst, notka.m_Tekst);
  33.             return *this;
  34.         }
  35.  
  36.     virtual ~Notatka(){
  37.         delete [] m_Tekst;
  38.     }
  39. };
  40.  
  41.         class Zadanie : public Notatka {
  42.         protected:
  43.             int m_iWykonane;
  44.            
  45.         public:
  46.             Zadanie (const Notatka& notatka, int wykon):Notatka(notatka) //Notatka note1; Zadanie zad1(note1, 2);
  47.             {
  48.                 m_iWykonane = wykon;
  49.  
  50.  
  51.  
  52.             }
  53.         };
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. int main() {
  62.    
  63.     char cos[]="dgh";
  64.    
  65.     Notatka n(cos);
  66.    
  67.     return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement