What does the c++ standard say about rain? It's been raining a lot here for the past two weeks. Maybe that has something to do with it, ya think? Maybe if I wait until the monsoon season is over, I'll hereby be complying with the standard and my code will compile.
No, what I meant to say was maybe then i wouldn't get stuck in the rut of 'undefined behavior'.
My program does compile, it just crashes when I try to free memory allocated for a string pointer.
http://paste.pocoo.org/ would have been nice in the future. (Bookmark it! It's better than pastebin!)
Could you at least tell us which function(s) wee need to be looking at for starters?
This is definitely an error: interest.~compound();
That aside, I'm not exactly sure what the compound class is for, but I highly doubt its usefulness - you can probably provide a functional equivalent with just a few lines of code. And the convert function is probably made obsolete by lexical_cast.
Well it compiles, and it was until i found the error causing me to crash, crashing without the call to the destructor, even when commenting out the delete [] s; line.
What i'm doing is just as an excercise really, maybe something usefull will come out of it, maybe not.
And tell me more about lexical cast?
And btw, I think i found the error, it was in bool what[8] not being initialized to false; ....
edit:
Besides I've always read and i strongly concur that its important to be able to, or at least know how to do many of the things that can be done with libraries. Plus I believe what I'm doing is called parsing, is it not? and that is supposedly one of the harder things to do, so I think that it makes for a pretty good excercize, even if I can't do anything with it when I'm done.
lexical_cast is part of boost and allows you to convert different types, e.g.: lexical_cast<string>(3.14) and lexical_cast<double>("3.14")
It's far more convenient than using a stringstream (and much faster too).
Plus I believe what I'm doing is called parsing, is it not? and that is supposedly one of the harder things to do, so I think that it makes for a pretty good excercize
Can I use lexical_cast<int, bool, float, double, char, string, char *>("He3llo w-245.1987orld!")
to cast that string into an int pointer = 3, a double pointer = -245.1987 a string * = "Hello" another string * = "world" and a char * for the space and the !?
No, you can only lexical_cast a type into one other type. If you want to do that (IMO strange) separation stuff you can separate it out then use lexical_cast.