Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef DBUFFER_H
- #define DBUFFER_H
- #include <ostream> // std::ostream
- template <typename T> //segnalazione della creazione template: ora dbuff è "templato" e potenzialmente generico
- class dbufferT {
- public:
- typedef unsigned int size_type;
- private:
- size_type _size;
- T * _buffer; //devo rimuovere i tipi concreti e mettere quelli templati: da int * _buffer a T *_buffer
- void init(size_type sz);
- public:
- dbuffer();
- explicit dbuffer(size_type sz);
- //dbuffer(size_type sz, int value); prima. Posso scrivere solo T value? no perchè T può essere qualsiasi cosa (anche un oggetto): non voglio più passare per copia ma per reference
- dbuffer(size_type sz, const T &value);
- dbuffer(const dbuffer &other);
- dbuffer& operator=(const dbuffer &other);
- ~dbuffer();
- size_type size(void) const;
- int &operator[](size_type index);
- const int &operator[](size_type index) const;
- void swap(dbuffer &other);
- };
- std::ostream &operator<<(std::ostream &os, const dbuffer &db);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement