Connecting Tech Pros Worldwide Help | Site Map

Constants and templates

  #1  
Old March 23rd, 2007, 11:55 AM
max.giacometti@gmail.com
Guest
 
Posts: n/a
Hi everybody!!!

I have a problem with templates and constants.

I have a template class

template<const int a, const int bclass...

Inside this class I have to use another template class, whose
parameter is function (the sum) of a and b.

How can I do that?


Thanks,



Massimiliano

  #2  
Old March 23rd, 2007, 12:05 PM
=?iso-8859-1?q?Erik_Wikstr=F6m?=
Guest
 
Posts: n/a

re: Constants and templates


On 23 Mar, 11:46, max.giacome...@gmail.com wrote:
Quote:
Hi everybody!!!
>
I have a problem with templates and constants.
>
I have a template class
>
template<const int a, const int bclass...
>
Inside this class I have to use another template class, whose
parameter is function (the sum) of a and b.
>
How can I do that?
You mean something like this?

template<int C>
class Foo
{
int i[C];
};


template<int A, int B>
class Bar
{
Foo<A+Bf;
};

int main()
{
Bar<1,2b;
}

--
Erik Wikström

  #3  
Old March 23rd, 2007, 12:15 PM
Rolf Magnus
Guest
 
Posts: n/a

re: Constants and templates


max.giacometti@gmail.com wrote:
Quote:
Hi everybody!!!
>
I have a problem with templates and constants.
>
I have a template class
>
template<const int a, const int bclass...
>
Inside this class I have to use another template class, whose
parameter is function (the sum) of a and b.
>
How can I do that?
otherclass<a+bmyobject;


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
question on c++ constants? shuisheng answers 54 October 22nd, 2008 04:15 PM
Floating Point Constants - Inlining Questions Leslie Sanford answers 2 August 4th, 2008 02:05 PM
Are C++ templates a precompiler thing? JohnQ answers 104 June 16th, 2007 12:35 AM
Object of Combination, an example of C++ templates programming Bo Xu answers 1 July 22nd, 2005 10:00 PM