Re: STL question: is this O/T ?
From: Dave Townsend (datownsend_at_comcast.net)
Date: 05/10/04
- Next message: David Harmon: "Re: Converting a string to an integer"
- Previous message: David Harmon: "Re: Using Polymortphism with streams"
- Maybe in reply to: Karthik: "Re: STL question: is this O/T ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 10 May 2004 14:01:16 -0700
Michael
The reason your code crashes is you have an invalid
index in:
void HuffmanNode::AddSubTreeToVector( vector<string>& v, string
currentString)
{
assert(this);
if(Represented != -1) v[Represented] = currentString;
The value of Represented is some negative number.
This is because the type of represented souldbe unsigned char,
not char, so you can stuff a 0..255 value in that.
dave
"Michael" <slick_mick_00@hotmail.com> wrote in message
news:c6vuq9$s83$1@titan.btinternet.com...
> Guys, thanks for advice on style but you haven't replied to my actual
> question, whats wrong with the code, why does it crash??
>
>
>
>
> "Rolf Magnus" <ramagnus@t-online.de> wrote in message
> news:c6ulcp$9u7$05$1@news.t-online.com...
> > Karthik wrote:
> >
> > > Andre Kostur wrote:
> > >
> > >
> > >>
> > >> Not required. If main ends without a return statement, it
> > >> effectively has
> > >> an automatic "return 0;". Stylistically speaking I prefer to always
> > >> have it in there anyway.....
> > >
> > > Might have been the case with a primitive compiler.
> >
> > If by 'primitive' you mean standard compliant.
> >
> > > Modern compilers refuse to compile, without that ( and it does make
> > > sense to be that way).
> >
> > It may make sense, but you should still replace those "modern compilers"
> > by old-fashioned
> >
> > > More than return 0, I would prefer still - EXIT_SUCCESS to make
> > > it complete.
> > >
> >
> > --
> > Prof: I'm sorry, Fry, but astronomers renamed Uranus in 2620
> > to end that stupid joke once and for all.
> > Fry: Oh. What's it called now?
> > Prof: Urectum.
> > (ü+#äfrom Futurama)
> > fro,.-m Futurama)
> >
>
>
- Next message: David Harmon: "Re: Converting a string to an integer"
- Previous message: David Harmon: "Re: Using Polymortphism with streams"
- Maybe in reply to: Karthik: "Re: STL question: is this O/T ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|