×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    56

    How to initialize array of integers?

    Hi. I need to create and initialize an array of inregers. But these code don't work.

    int testArray[] = {1, 2, 3};

    RArray<TInt> testArray = {1, 2, 3};

    Thanks.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: How to initialize array of integers?

    It is a bit more complex than that, since RArray is an object.
    But it seems to have a constructor for that
    Code:
    TInt init[]={1,2,3};
    RArray<TInt> testArray(sizeof(TInt),init,3);
    may work.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    56

    Re: How to initialize array of integers?

    Thanks for your help, but it didn't work.

    I declared this in header:

    TFixedArray<TInt,5>testArray;

    and filled it with integers (with Copy) in constructor. But when i try to reach any of it's elements in other methods, it says illegal use of non-static member.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: How to initialize array of integers?

    Ok, it works with almost any other type (like TReal, TInt8, even TInt32), but RArray<TInt> is a built-in specialization, which does not need the sizeof-thing
    Code:
    TInt init[]={1,2,3};
    RArray<TInt> testArray(init,3);

Similar Threads

  1. Replies: 3
    Last Post: 2009-07-09, 15:28
  2. reading integers from console application
    By JasonSmithMiller in forum Symbian
    Replies: 4
    Last Post: 2008-10-18, 17:24
  3. Replies: 2
    Last Post: 2008-04-20, 12:31
  4. Replies: 7
    Last Post: 2007-10-19, 21:31
  5. Create and write integers to the file
    By thngkl in forum Mobile Java General
    Replies: 4
    Last Post: 2007-03-22, 03:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×