P
Protoman
Can you help me figure out why this integer printing program won't
compile? I've looked far and wide in my diagnostics to figure out why,
but I'm lost. Here's the code:
#include <iostream>
#include <cstdlib>
using namespace std;
template<int I>
class _name
{
public:
static void f()
{
static int i=0;
cout << i << endl;
i++;
_name<go?(I-1):0>::f();
}
private:
enum {go=(I-1)!=0};
};
// Specialization provides base case for
// recursion
template<>
class _name<0>
{
public:
static void f(int i){return;}
};
int main()
{
// Equivalent loop code
_name<5>::f();
system("PAUSE");
return 0;
}
Any help, please? Thanks!!!!!
compile? I've looked far and wide in my diagnostics to figure out why,
but I'm lost. Here's the code:
#include <iostream>
#include <cstdlib>
using namespace std;
template<int I>
class _name
{
public:
static void f()
{
static int i=0;
cout << i << endl;
i++;
_name<go?(I-1):0>::f();
}
private:
enum {go=(I-1)!=0};
};
// Specialization provides base case for
// recursion
template<>
class _name<0>
{
public:
static void f(int i){return;}
};
int main()
{
// Equivalent loop code
_name<5>::f();
system("PAUSE");
return 0;
}
Any help, please? Thanks!!!!!