Click here to Skip to main content
15,891,375 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Windows Forms not available Pin
BlackDice10-Dec-04 9:50
BlackDice10-Dec-04 9:50 
GeneralScaleViewportExt and SetViewOrg related query Pin
JHAKAS10-Dec-04 3:40
JHAKAS10-Dec-04 3:40 
GeneralRe: ScaleViewportExt and SetViewOrg related query Pin
JHAKAS10-Dec-04 20:08
JHAKAS10-Dec-04 20:08 
GeneralSDI, MDI or dialog based Pin
help_cplus10-Dec-04 3:31
help_cplus10-Dec-04 3:31 
GeneralRe: SDI, MDI or dialog based Pin
Maximilien10-Dec-04 3:46
Maximilien10-Dec-04 3:46 
GeneralRe: SDI, MDI or dialog based Pin
help_cplus11-Dec-04 12:25
help_cplus11-Dec-04 12:25 
Generalreturning CMap object Pin
Tariq87810-Dec-04 1:55
Tariq87810-Dec-04 1:55 
GeneralRe: returning CMap object Pin
Antti Keskinen10-Dec-04 3:12
Antti Keskinen10-Dec-04 3:12 
The problem here is that CMap is a collection template class. Thus, you need to decide in the beginning what key-value pairs your map represents. Try this code piece for a size. I don't know if it compiles (haven't tested it), but as far as I can think of, there should be no syntactical errors in it.
class X
{
   CMap<int, int&, CPoint, CPoint&> m_map;
   ...<DIV>

   CMap<int, int&, CPoint, CPoint&>* GetMap() { return &m_map; }
   void SetMap( CMap<int, int&, CPoint, CPoint&>& m_refMap ) { m_map = m_refMap; }
   ...<DIV>

}
Something like that, I'd presume. I'm returning a pointer-to-member by design. You could return a reference from GetMap() as well. Also, I'm passing a reference to SetMap(). Again, passing a pointer and using pointer-dereferencing operator (*) is just as good a solution. Returning a copy from GetMap() is not preferred, because the map might be huge, thus creating a copy of it would cause unnecessary overhead.

All these solutions are not the best ones, however. When considering memory efficiency, the best way would be to keep a pointer-type member variable and using dynamic memory allocation in the class. This way, a direct pointer can be returned, and the SetMap() routine can use delete accompanied by a copy constructor call.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: returning CMap object Pin
Cedric Moonen10-Dec-04 4:11
Cedric Moonen10-Dec-04 4:11 
GeneralRe: returning CMap object Pin
Antti Keskinen10-Dec-04 4:44
Antti Keskinen10-Dec-04 4:44 
GeneralRe: returning CMap object Pin
Cedric Moonen10-Dec-04 5:10
Cedric Moonen10-Dec-04 5:10 
GeneralCListCtrl Text Color Pin
Neelesh K J Jain10-Dec-04 1:19
Neelesh K J Jain10-Dec-04 1:19 
GeneralRe: CListCtrl Text Color Pin
Jim Crafton10-Dec-04 6:38
Jim Crafton10-Dec-04 6:38 
Generalserial com / usb Pin
doneirik10-Dec-04 1:16
doneirik10-Dec-04 1:16 
GeneralRe: serial com / usb Pin
Cedric Moonen10-Dec-04 1:27
Cedric Moonen10-Dec-04 1:27 
GeneralRe: serial com / usb Pin
doneirik10-Dec-04 3:10
doneirik10-Dec-04 3:10 
GeneralRe: serial com / usb Pin
Antti Keskinen10-Dec-04 4:07
Antti Keskinen10-Dec-04 4:07 
GeneralRe: serial com / usb Pin
Trollslayer10-Dec-04 5:23
mentorTrollslayer10-Dec-04 5:23 
GeneralRe: serial com / usb Pin
doneirik13-Dec-04 1:37
doneirik13-Dec-04 1:37 
GeneralDebug Assertion failed Error Pin
Shailaja10-Dec-04 1:08
Shailaja10-Dec-04 1:08 
GeneralRe: Debug Assertion failed Error Pin
Cedric Moonen10-Dec-04 1:15
Cedric Moonen10-Dec-04 1:15 
GeneralRe: Debug Assertion failed Error Pin
Shailaja10-Dec-04 1:22
Shailaja10-Dec-04 1:22 
GeneralRe: Debug Assertion failed Error Pin
ThatsAlok10-Dec-04 1:24
ThatsAlok10-Dec-04 1:24 
GeneralRe: Debug Assertion failed Error Pin
Shailaja10-Dec-04 1:37
Shailaja10-Dec-04 1:37 
GeneralRe: Debug Assertion failed Error Pin
ThatsAlok10-Dec-04 2:16
ThatsAlok10-Dec-04 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.