Results 1 to 3 of 3

Thread: pointer arithmetics

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: pointer arithmetics

    Qt Code:
    1. int * data = new int[ width * height * depth ];
    2. int ** lut1 = new int *[width];
    3. int *** lut2 = new int **[width * height ];
    4.  
    5. for( int i = 0; i < width; ++i ) {
    6. lut1[i] = & lut2[width*i];
    7. for( int j = 0; j < height; ++j ) {
    8. lut1[i][j] = & data[height*(width*i + j)];
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 
    (not tested of course )

  2. #2
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: pointer arithmetics

    The, ehm, preferred way is to create a class that overloads the () operator, which can take any number of parameters. Separate subscripts should be used for jagged arrays, which this is not. It has the added advantage of making the allocation a lot easier.

    Just a suggestion.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

Similar Threads

  1. Delete auto pointer from QMultiMap
    By phillip_Qt in forum Qt Programming
    Replies: 5
    Last Post: 3rd December 2007, 17:29
  2. Passing a pointer in Signal/Slot Connection
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 6th November 2007, 19:04
  3. taking pointer out of bounds nicely
    By baray98 in forum General Programming
    Replies: 4
    Last Post: 21st October 2007, 00:33
  4. Pointer to ActiveX object in QT
    By json84 in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2007, 12:42
  5. QDataStream, QTreeWidgetItem, pointer
    By baca in forum Qt Programming
    Replies: 6
    Last Post: 16th February 2007, 16:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.