Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cv4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- class Pole{
- int *pole, a;
- public:
- //pole s jedním parametrem
- Pole(int a){
- pole=new int[this->a=a];
- }
- //pole s dvěma parametry
- Pole(int a, int p){
- pole=new int[this->a=a];
- for(int i=0;i<a;i++)
- pole[i]=p;
- }
- //Konverzni konstruktor
- Pole(char *c){
- int x=sizeof c;
- pole=new int[x];
- for(int i=0;i<x;i++)
- pole[i]=c[i];
- }
- //destruktor
- ~Pole(){
- delete[] pole;
- }
- //metoda pro nahodne veliciny
- void napln_pole(){
- for(int i=0;i<a;i++)
- pole[i]=rand()%50;
- }
- //metoda pro scitani
- void secti_pole(){
- }
- //metoda pro tisk
- void tisk(){
- for(int i=0;i<a;i++)
- cout << pole[i] << endl;
- }
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- //char c[3]=['A','B','C'];
- Pole p(4,5);
- p.napln_pole();
- p.tisk();
- cout<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement