func() { Object* pNext; func1(pNext); } func1(Object* pNext) { pNext = Segement->GetFirstPara(0); }
I expected this to be a pointer to firstpara returned from func1 (), but I see NULL, can someone explain and how to fix it to actually return a firstpara () pointer?
For C ++ only, you can make a parameter a link
func() { Object* pNext; func1(pNext); } func1(Object*& pNext) { pNext = Segement->GetFirstPara(0); }
. C . , (, Object ** Object * ). ++ ( &). , . , , ββ .
c :
func1(&pNext); func1(Object** pNext) { *pNext = ... }
++
func1(pNext); func1(Object*& pNext) { pNext = ... }
Object* func1, , . , pNext ( , ).
Object*
func1
, , .
, , .. Object** pNext. , . , , , .
Object** pNext
func() { Object* pNext; func1(&pNext); } func1(Object** pNext) { *pNext = Segement->GetFirstPara(0); }
, pNext, . NULL, , 0x12AbD468 - . :
if( NULL != pNext ) { pNext->DoSomething(); }
... , , - , .
, "func1()" pNext , :
func() { Object *pNext = func1(); } Object* func1() { return Segment->GetFirstPara(0); }
It should be
func() { Object *pNext; func1(&pNext); } void func1(Object **pNext) { *pNext = Segment->GetFirstPara(0); }
Source: https://habr.com/ru/post/1698161/More articles:NHibernate criteria: join two columns using an IN expression - nhibernateConnecting to an Informix Database from .Net - c #Why can't .NET parse a date string with a timezone? - datetimeIs it possible to set a default value when deserializing xml in C # (.NET 3.5)? - c #Debugging: runtime break on file change? (windows) - debuggingHas anyone used / created fisheye table columns? - javascriptAny alternative to ASP.NET page templates? - .netWhat are the best practices for developing consistent libraries? - pythonWhat is a good use case for tr1 :: result_of? - c ++Atoi () conversion error - c ++All Articles