mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Creation of OpenFOAM-dev repository 15/04/2008
This commit is contained in:
64
applications/test/alloc/test.C
Normal file
64
applications/test/alloc/test.C
Normal file
@ -0,0 +1,64 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
class Int
|
||||
{
|
||||
int I;
|
||||
|
||||
public:
|
||||
|
||||
Int(){}
|
||||
|
||||
operator int()
|
||||
{
|
||||
return I;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
class List : public T
|
||||
{
|
||||
T* v;
|
||||
int sz;
|
||||
|
||||
public:
|
||||
|
||||
List()
|
||||
{
|
||||
v = new T[sz=10];
|
||||
}
|
||||
|
||||
List(int s)
|
||||
{
|
||||
v = new T[sz=s];
|
||||
}
|
||||
|
||||
~List()
|
||||
{
|
||||
delete[] v;
|
||||
}
|
||||
|
||||
inline int size() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
inline int List<T>::size() const
|
||||
{
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
#include <stream.h>
|
||||
|
||||
main()
|
||||
{
|
||||
typedef List<Int> intList;
|
||||
|
||||
intList list(10);
|
||||
|
||||
cout << list.size() << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user