Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <typename T>
- class Container
- {
- protected:
- T * storage;
- size_t num_items;
- size_t storage_size;
- public:
- virtual void operator += (const T item) { }
- virtual ~Container() { }
- Container() : storage(nullptr), num_items(0), storage_size(0) { }
- T & operator [] (size_t index)
- {
- if (index < num_items)
- return storage[index];
- }
- size_t size() { return num_items; }
- };
- void main(int argc, char* argv[])
- {
- Container<long> * store = new Box(); // Συμπληρώστε την αρχικοποίηση
- // αντικειμένου της δικής σας κλάσης
- *store+=10L;
- *store+=20L;
- *store+=30L;
- for (size_t i=0; i<store->size(); i++)
- std::cout << (*store)[i] << " ";
- std::cout << std::endl;
- delete store;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement