The following code compiles on gcc, but cannot be executed. I got some
wierd message when executed:
1: Syntax error: ")" unexpected
Is there anything wrong in my function template?
#include <iostream>
using namespace std;
class DDComparePolicy
{
public:
static void Compare ()
{
cout<<"DDCompar ePolicy "<<endl;
}
};
class TDComparePolicy
{
public:
static void Compare ()
{
cout<<"TDCompar ePolicy "<<endl;
}
};
template <typename Policy>
void validateField()
{
Policy::Compare ();
}
template <typename Policy>
void validateAllFiel ds()
{
validateField<P olicy> ();
}
int main ()
{
string currentRecType ="A";
string lastRecType = "A";
if(currentRecTy pe == "A" && lastRecType == "A")
validateAllFiel ds<DDComparePol icy>();
else if(currentRecTy pe == "T" && lastRecType == "A")
validateAllFiel ds<TDComparePol icy>();
return 0;
}
wierd message when executed:
1: Syntax error: ")" unexpected
Is there anything wrong in my function template?
#include <iostream>
using namespace std;
class DDComparePolicy
{
public:
static void Compare ()
{
cout<<"DDCompar ePolicy "<<endl;
}
};
class TDComparePolicy
{
public:
static void Compare ()
{
cout<<"TDCompar ePolicy "<<endl;
}
};
template <typename Policy>
void validateField()
{
Policy::Compare ();
}
template <typename Policy>
void validateAllFiel ds()
{
validateField<P olicy> ();
}
int main ()
{
string currentRecType ="A";
string lastRecType = "A";
if(currentRecTy pe == "A" && lastRecType == "A")
validateAllFiel ds<DDComparePol icy>();
else if(currentRecTy pe == "T" && lastRecType == "A")
validateAllFiel ds<TDComparePol icy>();
return 0;
}
Comment