Obtain a pointer to data inside a trend items array - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22

Thread: Obtain a pointer to data inside a trend items array

  1. #16
    Join Date
    Oct 2010
    Posts
    18

    Re: Obtain a pointer to data inside a trend items array

    i just gave that to shiw the looping logic i am going through:

    pos = m_TrendItems[pen].GetTrendPoints().GetTailPosition();

    if(pos)
    trendpoint = m_TrendItems[pen].GetTrendPoints().GetPrev(pos);


    while(pos && trendpoint.m_time < m_selection.time)
    {
    trendpoint = m_TrendItems[pen].GetTrendPoints().GetPrev(pos );
    }


    .GetTrendPoints() returns m_TrendPoints which is of type

    typedef CList<CCsTrendPoint, CCsTrendPoint> CCsTrendPoints;


    so technically i am working on CList m_TrendPoints;

    m_TrendPoints.GetPrev(pos );

    Gets the list element identified by pos, then sets pos to the POSITION value of the previous entry in the list.

    now instead of getting the point, i want to get a pointer to the point something like:

    trendpoint* = &m_TrendPoints.GetPrev(pos );

    now, is the above code correct, will me pointer have a life as global, if so, how to make this pointer an global array, if so how to make the global array two dimensional, so that first dimension is pen and second dimension is index and value at it is the pointer

    something like trendpoint[pen][i]*, how to do this?

  2. #17
    Join Date
    Oct 2010
    Posts
    18

    Re: Obtain a pointer to data inside a trend items array

    continued.........


    trendpoint[pen][i]* = &m_TrendPoints.GetPrev(pos ); (where the point is start of 1st hour)

    trendpoint[pen][i]* = &m_TrendPoints.GetPrev(pos ); (where the point is start of second hour)

    trendpoint[pen][i]* = &m_TrendPoints.GetPrev(pos ); (where the point is start of third hour) etc

    like so for each pen.

  3. #18
    Join Date
    Apr 1999
    Posts
    27,423

    Re: Obtain a pointer to data inside a trend items array

    Quote Originally Posted by amara.fortheworld@gmail.com View Post
    i just gave that to shiw the looping logic i am going through:
    POSITIONS are not pointers -- POSITIONS are POSITIONS. It acts like a pointer, but it isn't one. It is similar to an STL "iterator". There is no interface to turn a POSITION into a pointer because the POSITION is your "pointer".

    So if you have a POSITION of something in the CList, then you have a "pointer" to what you want (even though technically, POSITIONS are not pointers).

    Regards,

    Paul McKenzie

  4. #19
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,050

    Re: Obtain a pointer to data inside a trend items array

    Quote Originally Posted by Paul McKenzie View Post
    POSITIONS are not pointers -- POSITIONS are POSITIONS. It acts like a pointer, but it isn't one. It is similar to an STL "iterator". There is no interface to turn a POSITION into a pointer because the POSITION is your "pointer".

    So if you have a POSITION of something in the CList, then you have a "pointer" to what you want (even though technically, POSITIONS are not pointers).

    Regards,

    Paul McKenzie
    Right. As I said earlier, you can use the POSITION to hop directly to any point in the list. Then GetNext or GetPrev to move backwards or forwards.

  5. #20
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,050

    Re: Obtain a pointer to data inside a trend items array

    Quote Originally Posted by amara.fortheworld@gmail.com View Post
    trendpoint* = &m_TrendPoints.GetPrev(pos );

    now, is the above code correct, will me pointer have a life as global, if so, how to make this pointer an global array, if so how to make the global array two dimensional, so that first dimension is pen and second dimension is index and value at it is the pointer

    something like trendpoint[pen][i]*, how to do this?
    That makes no sense at all to me.

  6. #21
    Join Date
    Apr 1999
    Posts
    27,423

    Re: Obtain a pointer to data inside a trend items array

    Quote Originally Posted by amara.fortheworld@gmail.com View Post
    now, is the above code correct, will me pointer have a life as global, if so, how to make this pointer an global array, if so how to make the global array two dimensional,
    Your terminology is very confusing.

    1) A pointer is not an array. You cannot turn a pointer into an array.

    2) You now want to turn this "array" into a two-dimensional array. You can't turn a one-dimensional array into 2-dimensions without defining what you mean by turning a 1-d array into a 2-d array.

    Regards,

    Paul McKenzie

  7. #22
    Join Date
    Apr 1999
    Posts
    27,423

    Re: Obtain a pointer to data inside a trend items array

    Quote Originally Posted by amara.fortheworld@gmail.com View Post
    continued.........
    You know what might be more beneficial -- you tell us what your high-level problem is that you're trying to solve, instead of telling us how you are "solving" it and having us try to make your solution work.

    That way, others can give you much better advice than trying to take what you think is a solution, and trying to make something work out of something that is unworkable.

    Regards,

    Paul McKenzie

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center