P
Protoman
I've been looking at template metaprogramming. It seems really cool,
make the compiler do most of the work. I have very simple program that
uses TMP,it calculates the square of a number, but it doesn't seem to
work. Here it is:
#include <iostream>
#include <cstdlib>
using namespace std;
template<int n>
class Sqr
{
public:
static const int RET = n*n;
};
Sqr sqr;
int main()
{
cout << sqr<10>::RET << endl;
system ("PAUSE");
return 0;
}
By all the websites I've read, this should work absolutely fine. Could
you help me? And, if it's any help, I'm using Bloodshed's Dev-Cpp
v4.9.9.2 compiler.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
make the compiler do most of the work. I have very simple program that
uses TMP,it calculates the square of a number, but it doesn't seem to
work. Here it is:
#include <iostream>
#include <cstdlib>
using namespace std;
template<int n>
class Sqr
{
public:
static const int RET = n*n;
};
Sqr sqr;
int main()
{
cout << sqr<10>::RET << endl;
system ("PAUSE");
return 0;
}
By all the websites I've read, this should work absolutely fine. Could
you help me? And, if it's any help, I'm using Bloodshed's Dev-Cpp
v4.9.9.2 compiler.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]