CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2010
    Posts
    121

    How to tie these attributes together (from two different classes)?

    Code:
    float npos[3];
    
    D3DXVECTOR3 m_position;


    something like
    Code:
    position = &npos[0];

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: How to tie these attributes together (from two different classes)?

    &npos[0] is of type float*. m_position is of type D3DXVECTOR3. Unless class D3DXVECTOR3 has an overloaded operator= (or constructor etc) for type float*, I'm not seeing how a type of D3DXVECTOR3 can be assigned from a type float*?

    To tie attributes together, there needs to be some way of associating one with the other. Your code/post doesn't say much about what is trying to be achieved??

    You could have a map as in
    Code:
    map<D3DXVECTOR3*, float*> mpos_npos;
    but without further info can't really provide much guidance.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Dec 2010
    Posts
    121

    Re: How to tie these attributes together (from two different classes)?

    Say in one module,
    npos is changed,
    so in m_position,
    it is directly showing that value immediately.
    Because in the module that contains npos,
    it actually add on to the m_position value.

    Say the m_position is changed by the pathfinder in one place.
    It is incremented by the collision avoider in another place.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to tie these attributes together (from two different classes)?

    Quote Originally Posted by luckiejacky View Post
    Code:
    float npos[3];
    
    D3DXVECTOR3 m_position;


    something like
    Code:
    position = &npos[0];
    Did you try one of the ctors mentioned in https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx ?
    Victor Nijegorodov

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: How to tie these attributes together (from two different classes)?

    I didn't realise that D3DXVECTOR3 was Microsoft - not being involved with graphics. . From the reference supplied by Victor in post #4, there is a constructor that takes a parameter of float* - as I queried in post #1. So
    Code:
    float npos[3];
    
    D3DXVECTOR3 m_position (npos);
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured