Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. // cv4.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. class Pole{
  9.  
  10. int *pole, a;
  11.  
  12. public:
  13. //pole s jedním parametrem
  14. Pole(int a){
  15.  
  16. pole=new int[this->a=a];
  17. }
  18. //pole s dvěma parametry
  19. Pole(int a, int p){
  20.  
  21. pole=new int[this->a=a];
  22. for(int i=0;i<a;i++)
  23. pole[i]=p;
  24.  
  25. }
  26. //Konverzni konstruktor
  27. Pole(char *c){
  28. int x=sizeof c;
  29. pole=new int[x];
  30. for(int i=0;i<x;i++)
  31. pole[i]=c[i];
  32.  
  33. }
  34. //destruktor
  35. ~Pole(){
  36.  
  37. delete[] pole;
  38. }
  39. //metoda pro nahodne veliciny
  40. void napln_pole(){
  41. for(int i=0;i<a;i++)
  42. pole[i]=rand()%50;
  43.  
  44. }
  45. //metoda pro scitani
  46. void secti_pole(){
  47.  
  48. }
  49. //metoda pro tisk
  50. void tisk(){
  51.  
  52. for(int i=0;i<a;i++)
  53. cout << pole[i] << endl;
  54. }
  55.  
  56. };
  57. int _tmain(int argc, _TCHAR* argv[])
  58. {
  59. //char c[3]=['A','B','C'];
  60.  
  61. Pole p(4,5);
  62.  
  63. p.napln_pole();
  64. p.tisk();
  65.  
  66. cout<<endl;
  67.  
  68.  
  69. system("pause");
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement