Problem in accessing nodes of a list in Release build
-
Hi, I am facing a problem while accessing values in a std::list in release build. The code I am using is like struct _STRUCT_ABC { int iIdCount; string szName; }STRUCTABC, *PSTRUCTABC; list<<PSTRUCTABC>>:: iterator ittr = g_ABCList.begin(); // g_ABCList is a golbal list with PSTRUCTABC int iCount = ittr._Ptr->_Myval->iIdCount; // Works fine with _DEBUG prepocessor but does not work in release mode if _DEBUG prepocessor is not defined. Now according to VS2005 compiler _Ptr is a private variable if _DEBUG is not defined. In that case how to access the values inside the list? Thanks in advance.
-
Hi, I am facing a problem while accessing values in a std::list in release build. The code I am using is like struct _STRUCT_ABC { int iIdCount; string szName; }STRUCTABC, *PSTRUCTABC; list<<PSTRUCTABC>>:: iterator ittr = g_ABCList.begin(); // g_ABCList is a golbal list with PSTRUCTABC int iCount = ittr._Ptr->_Myval->iIdCount; // Works fine with _DEBUG prepocessor but does not work in release mode if _DEBUG prepocessor is not defined. Now according to VS2005 compiler _Ptr is a private variable if _DEBUG is not defined. In that case how to access the values inside the list? Thanks in advance.
Aryan S wrote:
int iCount = ittr._Ptr->_Myval->iIdCount;
you don't like the public interface of the list (and its iterator), do you?
int iCount = ittr->iIdCount;
int iCount = (*ittr)->iIdCount;[thanks to] Cedric's post [/thanks to] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Monday, June 23, 2008 5:32 AM
-
Hi, I am facing a problem while accessing values in a std::list in release build. The code I am using is like struct _STRUCT_ABC { int iIdCount; string szName; }STRUCTABC, *PSTRUCTABC; list<<PSTRUCTABC>>:: iterator ittr = g_ABCList.begin(); // g_ABCList is a golbal list with PSTRUCTABC int iCount = ittr._Ptr->_Myval->iIdCount; // Works fine with _DEBUG prepocessor but does not work in release mode if _DEBUG prepocessor is not defined. Now according to VS2005 compiler _Ptr is a private variable if _DEBUG is not defined. In that case how to access the values inside the list? Thanks in advance.
What are you doing :confused: ? That's not the way to work with iterators. You hsould simply dereference them:
int iCount = (*ittr)->iIdCount;
Cédric Moonen Software developer
Charting control [v1.4] -
What are you doing :confused: ? That's not the way to work with iterators. You hsould simply dereference them:
int iCount = (*ittr)->iIdCount;
Cédric Moonen Software developer
Charting control [v1.4] -
Aryan S wrote:
I am actually new in this field... :(
There are a lot of tutorials on the web, it would be much more efficient to read some of them before going any further developing code with tools that you don't how to use. Check this[^] for instance.
Cédric Moonen Software developer
Charting control [v1.4]