C++学习----类模板
2011-03-23 10:56
239 查看
#include
using namespace std;
template
class ArrayClass
{
private:
T1 Value1[10];
public:
void SetValue1()
{
for (int i=0; i<10; i++)
{
Value1[i] = i;
}
};
T1 & GetValue1()
{
return Value1[0];
};
};
int main()
{
int mInt[10];
int *mIntRecv;
ArrayClass CInt;
CInt.SetValue1();
mIntRecv = &CInt.GetValue1();
for(int i=0; i<10; i++)
{
mInt[i] = *(mIntRecv+i);
}
for (int k=0; k<10; k++)
{
cout<
using namespace std;
template
class ArrayClass
{
private:
T1 Value1[10];
public:
void SetValue1()
{
for (int i=0; i<10; i++)
{
Value1[i] = i;
}
};
T1 & GetValue1()
{
return Value1[0];
};
};
int main()
{
int mInt[10];
int *mIntRecv;
ArrayClass CInt;
CInt.SetValue1();
mIntRecv = &CInt.GetValue1();
for(int i=0; i<10; i++)
{
mInt[i] = *(mIntRecv+i);
}
for (int k=0; k<10; k++)
{
cout<