109 Posted Topics
Re: I would create more of a deck than you have right now, and treat it as a stack. You would have 52 cards, each card would have a suit, a face, and a value, and you can shuffle and deal from it easily. [code] #include <algorithm> #include <iostream> #include <string> … | |
Re: You're adding a constant number of items onto a variable number of lines. When you have a constant number of items, the big O is almost always going to be O(1) and when you have a variable number of items but you do a constant operation on every item, the … | |
Re: [QUOTE]"Debug Assertion Failed!"and with "Expression:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)"[/QUOTE] When you get that it means that somehow you corrupted your memory and the allocator isn't getting what it expects to free it. The bug is almost never near the delete operator, and it could be anywhere. In the case of memory bugs, post all … | |
Re: [QUOTE=JRM;295149]I'm just trying to get a handle on the when and why of overloaded operators.[/QUOTE] Cool. :) [QUOTE=JRM;295149]the line: T& operator[] ... is there for use in the copy constructor?[/QUOTE] Nah, the copy constructor doesn't invoke the overloaded operator at all, it uses the [] operator for pointers. [QUOTE=JRM;295149]the line … | |
Re: Big O takes the biggest part of the time expression because it has the biggest effect. :) As n gets bigger and bigger, the log n part will get less and less significant as the n^2 part starts to dominate. Since you can toss anything smaller than n^2 in the … | |
Re: It's implementation defined what happens when you use an unrecognised character literal. You use '10', and that has too many expected characters, and C++ is seeing it as '0'. [code] #include <cstdio> int main() { using namespace std; char x = '10'; printf( "%d\t%c\n", x, x ); } [/code] | |
Re: I don't understand the question. Can you explain it a different way please? | |
Re: [quote]I know that you cannot judge a book by it's size but I am a little worried that Accelerated C++ will not go as far in depth as the other two.[/quote] That's because with Accelerated C++ you get all the meat and none of the empty calories. :) It basically … | |
Re: [QUOTE]How do I get smart pointer from pointer address?[/QUOTE] You can't. Smart pointers are smart, but regular pointers are very dumb. They don't know which objects they belong to, or even if they belong to an object at all. The only way to figure it out is by coming up … |
The End.