Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- using namespace std;
- template<class T>
- class Vetor
- {
- T *vet;
- int tam;
- public:
- Vetor(int n)
- {
- vet = new T(n);
- tam=n;
- }
- ~Vetor();
- void LeiaVetor();
- void ImprimaVetor();
- };
- template<class T>
- Vetor<T>::~Vetor()
- {
- delete []vet;
- cout << "destrutor";
- };
- template <class T>
- void Vetor<T>::LeiaVetor()
- {
- cout << "Digite o vetor\n";
- int *p;
- p=vet;
- for (int i=0 ; i<tam ; i++)
- {
- cin >> *p;
- p++;
- }
- };
- template <class T>
- void Vetor<T>::ImprimaVetor()
- {
- cout << "O vetor que vc digitou\n";
- int *p;
- p=vet;
- for(int i=0 ; i<tam ; i++)
- {
- cout << *p << " ";
- p++;
- }
- };
- int main()
- {
- Vetor<int> V(10);
- V.LeiaVetor();
- V.ImprimaVetor();
- }
Advertisement
Add Comment
Please, Sign In to add comment