U++ framework
Do not panic. Ask here before giving up.

Home » Community » Newbie corner » Void pointer to NTL Array and VectorMap
Re: Void pointer to NTL Array and VectorMap [message #26400 is a reply to message #26390] Fri, 30 April 2010 00:01 Go to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
[quote title=manfhe wrote on Thu, 29 April 2010 13:14]Hello

I have a void pointer to an NTL Array and VectorMap, how do I receive the elements through the key?
The code looks like this:


	typedef VectorMap<String, String> ntlMap;
	typedef Array<String> ntlArray;
	
	void* ptra;
	void* ptrm;
	
	ptra = new ntlArray;
	ptrm = new ntlMap;
	
	for(int i = 0; i < ((ntlMap*)ptrm)->GetCount(); i++)
		((ntlArray*)ptra)->???? = ((ntlMap*)ptrm)->????;


Or you can do this:

ntlMap& map = *(ntlMap *)ptrm;
ntlArray& array = *(ntlArray *)ptra;
for(int i = 0; i < map.GetCount(); i++)
     array[i] = map[i];


BTW, I only hope that you are doing something really special Smile

Using 'new' should be reserved only for really desperate cases Smile

Quote:


And I would like to thank all contributors to this project. For beginners in C + + as I, U + + is a true teacher.

Grateful, Alan


Only be aware that U++ will teach you something little bit different from "classic" approach...
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: image drawing
Next Topic: [SOLVED]destroying self from array
Goto Forum:
  


Current Time: Fri Jul 03 16:32:55 GMT+2 2026

Total time taken to generate the page: 0.00518 seconds