i have changed code style and aslo i hope it will help http://www.cs.bell-labs.com/cm/cs/pearls/spacemod.cpp
#include <iostream>
using namespace std;
#define MEASURE(T, text)
{
int i;
cout<<text<<" ";
cout<<sizeof(T)<<" ";
int lastp=0;
for ( i=0;i<11;i++){
T *p=new T;
int thisp=(int)p;
if (lastp!=0) cout<<" "<<thisp-lastp;
lastp=thisp;
}
cout<<"n";
}
using namespace std;
template <class T>
void measure(char *text)
{
cout<<"measure"<<text<<" ";
cout<<sizeof(T)<<"
";
}
int main(){
return 0;
}
它只有一个错误。
1>c:usersdaviddocumentsvisual studio 2010projectsmeasuremeasure.cpp(5): error C2447: { : missing function header (old-style formal list?)