Thread: GCC:Static(fixed-length) array in template class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2010
    Location
    norway
    Posts
    3

    GCC:Static(fixed-length) array in template class

    Hi.

    I'm using GCC's c++ compiler, and when attempting to create a template class containing an N-length array;

    Code:
    template <int N>
    class C
    {
    public:
        { ... }
    private:
        { ... }
        int _array[N];
    };
    ... and start using(i.e. calling functions manipulationg C::_array) a single instance of the class; everything is fine. But when several instances exist, the array is zeroed-out, and stays that way.

    If I use a dynamic array, then no problem. Is there any way to get fixed-length arrays as class-members in GCC-c++?

    Thanks in advance!
    Last edited by tra86; 06-19-2011 at 01:52 PM. Reason: Unclarity

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Static member initialization with class template
    By threahdead in forum C++ Programming
    Replies: 6
    Last Post: 04-28-2011, 12:16 AM
  2. how to define a static member in a template class
    By wanziforever in forum C++ Programming
    Replies: 3
    Last Post: 10-08-2009, 04:44 AM
  3. Linking error with static template class members
    By cunnus88 in forum C++ Programming
    Replies: 6
    Last Post: 04-02-2009, 12:31 PM
  4. tricky: static int on template class;
    By FillYourBrain in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2002, 04:03 PM
  5. bug for static functions in template class
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2001, 06:38 PM