变量指针作为模板参数

用作模板参数的变量指针必须指向全局变量
 
#include "stdafx.h"
#include <string>
#include <iostream>
 
template<const std::string* pContent>
class Test
{
public:
    void fun()
    {
        std::cout << *pContent << std::endl;
    }
};
std::string sContent = "Hello, world";
int _tmain(int argc, _TCHAR* argv[])
{
    Test<&sContent> val;
    val.fun();
    return 0;
}
posted @ 2012-09-03 14:44  胖胖熊  阅读(362)  评论(0编辑  收藏  举报