Advertisement
neogz

KLASE - public, create, show

Nov 6th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Osoba{
  5.     public:
  6.         char ime[14];
  7.         char prezime[14];
  8.         int godine;
  9.        
  10.         void create(char * i, char * p, int g);
  11.         void predstaviSe();
  12. };
  13.  
  14. void Osoba::create(char * i, char * p, int g){
  15.     int velI = strlen(i) + 1;
  16.     int velP = strlen(p) + 1;
  17.  
  18.     strcpy_s(ime, velI, i);
  19.     strcpy_s(prezime, velP, p);
  20.  
  21.     godine = g;
  22.  
  23. }
  24. void Osoba::predstaviSe(){
  25.     cout << "Ime: " << ime << endl << "Prezime: " << prezime << endl << "Godine: " << godine << endl <<endl;
  26. }
  27.  
  28. int main(){
  29.  
  30.     Osoba a, b, c;
  31.     a.create("Nedim", "Fejzic", 32);
  32.     b.create("Saldina", "Nurak", 13);
  33.     c.create("Mirnes", "Turkovic", 18);
  34.  
  35.     a.godine = 19;
  36.     b.godine = 19;
  37.     c.godine = 20;
  38.  
  39.     a.predstaviSe();
  40.     b.predstaviSe();
  41.     c.predstaviSe();
  42.  
  43.     system("pause > null");
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement