Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem for template class<class_name> that has bitset as argument
    text
    copied!<p>I want to write a class in C++ in which one of the parameter is a <code>bitset&lt;size&gt;</code>. I want to give the facility to vary this "size" for any object of that class but should be constant for that object.</p> <p>If I make a variable <code>const int size;</code> and initialize it in the constructor, then it does not compile because to writiting <code>bitset&lt;size&gt;</code> would require <code>size</code> to be static which would make it same for all objects of the class.</p> <p>Is there any other method than making a class template and passing the size as <code>classname&lt;size&gt;</code>?</p> <p>thanks but.. but this makes this Foo class objects whenever used as composition (object as data member)... would it be necessary to again make that class template. I made a class and Passed a (#define BIT_SIZE 16 to Foo bits;) it is giving compile errors undefined reference to Foo&lt;16>::Foo(). where Foo() is the constructor. I thought it should work because that is also compile time. and i just wanted to make only size BIT_SIZE bits. should i make my "next level" class template ?? it can be that these errors were because of other mistakes. but i checked that again and again.</p> <hr> <p>yes sir i have implemented that and but included the header files and not cpp files .......... when i changed these to cpp files ... multiple declaration error came. i am working on linux ubuntu .. when i took these files to dev_cpp in windows that worked . may be because compiler did that automatically what i need to do. so what is that i need to do.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload