注册 登录
编程论坛 C++教室

模板出错误了!请大虾帮忙!

lixang 发布于 2007-09-28 21:19, 436 次点击
#include<iostream>
using namespace std;

template< class T>
struct S
{
template< bool Cmd>
class Select { };

template<>
class Select<true>
{
static void sta1() {cout<<"this is Sta1"<<endl;}
public:
static void f(){ sta1(); }
};

template<>
class Select<false>
{
static void sta2() {cout<<"this is Sta2"<<endl;}
public:
static void f(){ sta2(); }
};
};

template<bool cmd>
void execute() { Select<cmd>::f();}
int main()
{
execute<sizeof(int)==4>();
}
2 回复
#2
lixang2007-09-28 21:20
我用的是VS2005
#3
faee02007-10-04 15:39
眼睛都看花了
1