Click here to Skip to main content
15,892,737 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: writing Bitmap data as Binary Into XML file Pin
CPallini6-Aug-09 21:11
mveCPallini6-Aug-09 21:11 
QuestionCan CSocket be used in this way? Pin
includeh106-Aug-09 18:30
includeh106-Aug-09 18:30 
AnswerRe: Can CSocket be used in this way? Pin
«_Superman_»6-Aug-09 18:52
professional«_Superman_»6-Aug-09 18:52 
AnswerRe: Can CSocket be used in this way? Pin
Rajesh R Subramanian6-Aug-09 19:46
professionalRajesh R Subramanian6-Aug-09 19:46 
AnswerRe: Can CSocket be used in this way? Pin
Moak8-Aug-09 8:28
Moak8-Aug-09 8:28 
Questionafter calling GetCurrentBuffer(&lBufferSize,NULL), lBufferSize is minus value. Pin
rambojanggoon6-Aug-09 16:52
rambojanggoon6-Aug-09 16:52 
AnswerRe: after calling GetCurrentBuffer(&lBufferSize,NULL), lBufferSize is minus value. Pin
Cedric Moonen6-Aug-09 20:29
Cedric Moonen6-Aug-09 20:29 
QuestionUsing a map with an class inherited from pair. Pin
thelonesquirrely6-Aug-09 14:11
thelonesquirrely6-Aug-09 14:11 
Hey,

So I am just trying to utilize some of the built-ins for from the stl containers. I want to be able to store a class in a map, using one of the params as the key, and then retrieve it via an iterator.

It looks like this:

typedef std::string NodeName;
typedef std::set<NodeName> NodeSet;
typedef std::map<NodeName, NodeSet> NodeMap;

class Node : public std::pair <NodeName, NodeSet>

NodeMap NMap;

...some code...

I can insert objects easily enough:

Node n (...);
NMap.insert (n);

lets say i do that a bunch.
I then want to iterator over the map, extracting the data as I go.

for (NodeMap::iterator it = NMap.begin (); it != NMap.end (); it++)
{
Node &node = *it; <-- fails
}
I get the following error:
"~/testing/nodelist% g++ NodeList.C
NodeList.C: In function âvoid compute()â:
NodeList.C:40: error: cannot dynamic_cast â& itâ (of type âstruct std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::set<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >*â) to type âclass Node*â (source type is not polymorphic)
NodeList.C:51: error: âclass std::set<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >â has no member named âneighborhoodâ
"


I tried dynamic casting but i couldn't seem to find it properly. Is there a legal way that I can do this? In the node class I made some handy little functions (nothing special), and I'd really like to be able to use them.

Could you please point out what my mistake is?
AnswerRe: Using a map with an class inherited from pair. Pin
Garth J Lancaster6-Aug-09 14:42
professionalGarth J Lancaster6-Aug-09 14:42 
Questiontime and space complexity? Pin
sam_psycho6-Aug-09 8:35
sam_psycho6-Aug-09 8:35 
AnswerRe: time and space complexity? Pin
Luc Pattyn6-Aug-09 9:04
sitebuilderLuc Pattyn6-Aug-09 9:04 
GeneralRe: time and space complexity? Pin
sam_psycho6-Aug-09 9:38
sam_psycho6-Aug-09 9:38 
AnswerRe: time and space complexity? Pin
CPallini6-Aug-09 10:21
mveCPallini6-Aug-09 10:21 
GeneralRe: time and space complexity? Pin
sam_psycho6-Aug-09 10:29
sam_psycho6-Aug-09 10:29 
AnswerRe: time and space complexity? Pin
RomanMzh6-Aug-09 13:15
RomanMzh6-Aug-09 13:15 
AnswerRe: time and space complexity? Pin
Adam Roderick J6-Aug-09 17:48
Adam Roderick J6-Aug-09 17:48 
QuestionCAsynSocket CWinthread Question Pin
ForNow6-Aug-09 6:39
ForNow6-Aug-09 6:39 
AnswerRe: CAsynSocket CWinthread Question Pin
sashoalm6-Aug-09 22:10
sashoalm6-Aug-09 22:10 
GeneralRe: CAsynSocket CWinthread Question Pin
ForNow7-Aug-09 1:02
ForNow7-Aug-09 1:02 
GeneralRe: CAsynSocket CWinthread Question Pin
sashoalm7-Aug-09 1:50
sashoalm7-Aug-09 1:50 
GeneralRe: CAsynSocket CWinthread Question Pin
ForNow7-Aug-09 12:10
ForNow7-Aug-09 12:10 
GeneralRe: CAsynSocket CWinthread Question Pin
ForNow7-Aug-09 12:18
ForNow7-Aug-09 12:18 
GeneralRe: CAsynSocket CWinthread Question Pin
sashoalm8-Aug-09 1:15
sashoalm8-Aug-09 1:15 
GeneralRe: CAsynSocket CWinthread Question Pin
ForNow9-Aug-09 2:35
ForNow9-Aug-09 2:35 
GeneralRe: CAsynSocket CWinthread Question Pin
sashoalm9-Aug-09 23:01
sashoalm9-Aug-09 23:01 

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.