Advertisement
Guest User

zad

a guest
Nov 24th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4. using namespace std;
  5.  
  6. class Osoba{
  7. protected:
  8.     char ime,prezime,spol;
  9. public:
  10.     Osoba(){
  11.         ime='i';prezime='p';spol='m';
  12.     }
  13.     Osoba(char i,char p, char s){
  14.         ime=i;prezime=p;spol=s;
  15.     }
  16.     void postavi_atribute_o (char i, char p, char s){
  17.     ime=i;prezime=p;spol=s;
  18.     }
  19.     void ispisi_atribute_o (){
  20.    
  21.         cout<<ime<<prezime<<spol<<endl;
  22.     }
  23. };
  24. class Ucenik :public Osoba{
  25. protected:
  26.     char  odjeljenje, ime_skole;
  27.     int razred;
  28. public:
  29.     Ucenik(){
  30.         razred=1;odjeljenje='a';ime_skole='o';Osoba();
  31.     }
  32.     Ucenik(char i,char p, char s,int r,char o, char is){
  33.         razred=r;odjeljenje=o;ime_skole=is;Osoba(i,p,s);
  34.     }
  35. void postavi_atribute_u (int r, char o, char is,char i,char p,char s){
  36.     postavi_atribute_o(i,p,s);razred=r;odjeljenje=o;ime_skole=is;
  37.     }
  38.  
  39. void ispisi_atribute_u (){
  40. ispisi_atribute_o ();
  41.     cout<<razred<<odjeljenje<<ime_skole<<endl;
  42. }
  43. };
  44. class Student :public Osoba{
  45. protected:
  46.     char fakultet;
  47.     int semestar,  broj_indeksa;
  48. public:
  49.     Student(){
  50.         fakultet='e';semestar=3;broj_indeksa=1200;Osoba();
  51.     }
  52.     Student(char i,char p, char s,char f,int se, int br ){
  53. Osoba(i,p,s);
  54.         fakultet=f;semestar=se;broj_indeksa=br;
  55.     }
  56. void postavi_atribute_s (char f,int se, int br,char i,char p,char s){
  57.     postavi_atribute_o(i,p,s);fakultet=f;semestar=se;broj_indeksa=br;
  58.     }
  59.  
  60. void ispisi_atribute_s (){
  61. ispisi_atribute_o ();
  62.     cout<<fakultet<<semestar<<broj_indeksa<<endl;
  63. }
  64. };
  65.  
  66. int main()
  67. {
  68.     Ucenik U1('i','p','m',5,'a','o');
  69. Student S1('i','p','m','e',6,100);
  70.     U1.postavi_atribute_u('i','p','m',5,'a','o');
  71. S1.postavi_atribute_s('i','p','m','e',6,100);
  72. U1.ispisi_atribute_u();
  73. S1.ispisi_atribute_s();
  74. _getch();
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement