Example code The Art of C++
#include <iostream>
#include <new>
#include "gc.h"
using namespace std;
int main() {
GCPtr<int> p;
try {
p = new int;
} catch(bad_alloc exc) {
cout << "Allocation failure!\n";
return 1;
}
*p = 88;
cout << "Value at p is: " << *p << endl;
int k = *p;
cout << "k is " << k << endl;
return 0;
}
其中gc.h比较长就不贴了!
http://shop.osborne.com/cgi-bin/osborne/0072255129.html可下载到代码!
代码是不会有问题的,可是我在VC6.0中却怎么也用不了!
Windows 32 Application
Windows 32 Console Application
MFC
都试过了!就是不知要怎么才能让它可以运行!
而且单独对gc.h编译都通不过!