template problems
-
Hi everyone, I am having problems trying to use a templated function. I have a templated function like so: template bool SetCellStyle(int row, int column, const T & value) Now I call the function like this for example: void MyFunc(int value) { objectPointer->SetCellStyle(row, column, value); } This results in the following error: error C2275: 'int' : illegal use of this type as an expression. I do not know why I am not allowed to do this. I would really appreciate some help here. Thanks, Pankaj /** I'm the one who's gonna have to die When it's time for me to die So let me live my life The way I want to - Jimi Hendrix */
-
Hi everyone, I am having problems trying to use a templated function. I have a templated function like so: template bool SetCellStyle(int row, int column, const T & value) Now I call the function like this for example: void MyFunc(int value) { objectPointer->SetCellStyle(row, column, value); } This results in the following error: error C2275: 'int' : illegal use of this type as an expression. I do not know why I am not allowed to do this. I would really appreciate some help here. Thanks, Pankaj /** I'm the one who's gonna have to die When it's time for me to die So let me live my life The way I want to - Jimi Hendrix */
Hello, first of all please turn the "Do not treat <'s as HTML tags" checkbox on when posting code, so that
<
s are shown properly. I reproduce here your code (with brackets):template <class T>
bool SetCellStyle(int row, int column, const T & value)void MyFunc(int value)
{
objectPointer->SetCellStyle<int>(row, column, value);
}Is
MyFunc
by chance a member function of a class template? If so, maybe you're being hit by a nasty problem with so called dependent contexts. Please try the following and report the results:void MyFunc(int value)
{
objectPointer-> template SetCellStyle<int>(row, column, value);
}Did that work? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!
-
Hi everyone, I am having problems trying to use a templated function. I have a templated function like so: template bool SetCellStyle(int row, int column, const T & value) Now I call the function like this for example: void MyFunc(int value) { objectPointer->SetCellStyle(row, column, value); } This results in the following error: error C2275: 'int' : illegal use of this type as an expression. I do not know why I am not allowed to do this. I would really appreciate some help here. Thanks, Pankaj /** I'm the one who's gonna have to die When it's time for me to die So let me live my life The way I want to - Jimi Hendrix */
-
Hi! Thanks. The whole problem was the in the call. It behaves ok when I use objectPointer->SetCellStyle(row, column, value) instead of objectPointer->SetCellStyle(row, column, value); I have no idea why. I thought after VS 5.0 this problem disappeared. I am going to try it with VS 7 to see what happens. Cheers, Pankaj /** I'm the one who's gonna have to die When it's time for me to die So let me live my life The way I want to - Jimi Hendrix */