Don't like ads? PRO users don't see any ads ;-)

4

By: rod1231234 on May 5th, 2012  |  syntax: C++  |  size: 0.64 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. class Vetor
  7. {
  8.     int *vet;
  9.     int tam;
  10. public:
  11.     Vetor(int n)
  12.     {
  13.         vet = new int [n];
  14.         tam=n;
  15.     };
  16.     ~Vetor( )
  17.     {
  18.         delete []vet;
  19.     };
  20.     void LeiaVetor ( )
  21.     {
  22.         for(int i=0;i<tam;i++)
  23.         {
  24.             cout << "Vet" << "[" << i << "]:";
  25.             cin >> vet[i];
  26.             cout << "\n";
  27.         }
  28.     };
  29.     void ImprimaVetor( )
  30.     {
  31.         for(int i=0;i<tam;i++)
  32.             cout << "Vet" << "[" << i << "]:" << vet[i] << "\n";
  33.     };
  34. };
  35. int main(void)
  36. {
  37.     Vetor V(10);
  38.     V.LeiaVetor( );
  39.     V.ImprimaVetor();
  40. };