C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Creating functions sequentialy

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
sergio
Guest





PostPosted: Wed Sep 28, 2005 9:49 am    Post subject: Creating functions sequentialy Reply with 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>

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]>:Razz;

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





PostPosted: Wed Sep 28, 2005 1:48 pm    Post subject: Re: Creating functions sequentialy Reply with quote



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]>:Razz;

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





PostPosted: Wed Sep 28, 2005 1:50 pm    Post subject: Re: Creating functions sequentialy Reply with quote



"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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.