006
20.09.2007, 20:59 Uhr
xXx
Devil
|
@FloSoft: Geht sowas nicht?
C++: |
template <typename T> class foo { T* m_data; std::size_t m_size:
public: foo(std::size_t size) : m_size(size) { m_data = new T[m_size]; }
public: void push_back(T const& data) { T* tmp = new T[m_size + 1]; std::memcpy(tmp, m_data, sizeof(T) * m_size); delete m_data; m_data = tmp; m_data[m_size++] = data; } };
class bar { struct data { unsigned int a; unsigned int b; data(unsigned int a, unsigned int b) : a(a), b(b) {} } m_data; public: bar(unsigned int a, unsigned int b) : m_data(a, b) {} };
int main() { foo<bar> inst; inst.push_back(bar(10, 11)); }
|
Das soll nicht gehen? Glaub ich jetzt nicht |