 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
sergio Guest
|
Posted: Wed Sep 28, 2005 9:49 am Post subject: Creating functions sequentialy |
|
|
Hi, I was trying to implement functions with data associted to it
sequentialy, I tried the following way(below), but that does not comply
with the compiler norms for C++ even though that's not any semantic or
sintax error..., does any one knows a way to do that?
Thanks
Code:
#include <iostream.h>
template<int *INT_POINTER>
class ClassA
{
public:
static void P(){}
};
int x[3];
typedef void(*VOIDFUNCVOID)();
VOIDFUNCVOID functions[3];
int main()
{
for(int i=0;i<3;i++)
/*error C2964: invalid expression as template parameter*/
functions[i]=ClassA<&x[i]>: ;
return 0;
}
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Daniel Krügler Guest
|
Posted: Wed Sep 28, 2005 1:48 pm Post subject: Re: Creating functions sequentialy |
|
|
sergio wrote:
| Quote: | Hi, I was trying to implement functions with data associted to it
sequentialy, I tried the following way(below), but that does not comply
with the compiler norms for C++ even though that's not any semantic or
sintax error..., does any one knows a way to do that?
Thanks
Code:
#include <iostream.h
|
This is a pre-standard header, I assume you mean:
#include
| Quote: | template<int *INT_POINTER
class ClassA
{
public:
static void P(){}
};
int x[3];
typedef void(*VOIDFUNCVOID)();
VOIDFUNCVOID functions[3];
int main()
{
for(int i=0;i<3;i++)
/*error C2964: invalid expression as template parameter*/
functions[i]=ClassA<&x[i]>: ;
return 0;
}
|
See answers to your previous thread "Compiling error".
Greetings from Bremen,
Daniel Krügler
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
pavana.murthy@gmail.com Guest
|
Posted: Wed Sep 28, 2005 1:50 pm Post subject: Re: Creating functions sequentialy |
|
|
"Addresses of array elements are not valid template arguments
according"
of 14.3.2 of the C++ Standard.
A similar query has been answered (very)recently in this group. Please
refer the same for more explanation.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|