CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2015
    Posts
    500

    Reference to outer struct doesnot update

    Hello,

    I have a function:
    Code:
    
    void FiveGServiceGeneralPage::SaveValues()         
    {
    	FiveGServiceParams& fivegParams = m_pCurrentService->Get5gParams();
    	
    ::::::::::::
    	// MOS Lookup
    	if (m_pSimulatedCurveMOSCombo->Handle)
    	{
    		const SimulatedCurve* pSimulatedCurveMOS = reinterpret_cast<const SimulatedCurve*>(m_pSimulatedCurveMOSCombo->GetItemData(m_pSimulatedCurveMOSCombo->GetSelIndex()));
    		fivegParams.SetSimulatedCurveMOS(pSimulatedCurveMOS);
    	}
    :::
    Im seeing that ( while debug), the fivegParams.m_pSimulatedCurveMOS has valid data input in the dialog page, but the parent reference (i.e m_pCurrentService->m_pSimulatedCurveMOS) does not get updated ...eventhough its reference !!!

    In the debugger, the struct within the fivegcellparams has different memory address

    fivegParams.m_pSimulatedCurveMOS 0x000000003a5e3df0
    m_pCurrentService->m_pSimulatedCurveMOS 0x000000003a5e37f0

    please kindly help with the inputs
    Last edited by pdk5; February 6th, 2022 at 07:20 AM.

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

    Re: Reference to outer struct doesnot update

    What is the return type of get5gParams(). Is it a reference?
    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
    May 2015
    Posts
    500

    Re: Reference to outer struct doesnot update

    Quote Originally Posted by 2kaud View Post
    What is the return type of get5gParams(). Is it a reference?
    Thanks a lot kaud, for looking into this and helping me
    Yes, it is reference (its legacy code)

    FiveGServiceParams& TGService::Get5gParams()
    {
    return m_5gParams;
    }

  4. #4
    Join Date
    May 2015
    Posts
    500

    Re: Reference to outer struct doesnot update

    sorry it was my mistake, they also defined new class in the m_pCurrentService also.. it looks like something wrong in design (it is there in two places)..getting updated one place..accessed somewhere else !!!..

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
  •  





Click Here to Expand Forum to Full Width

Featured