Forum: C++ Jan 14th, 2009 |
| Replies: 8 Views: 545 You're developing a realtime application, and don't know how to add values to elements of an array?????
Pull my other leg: it'll play a tune for you.
What is the criterion by which you would... |
Forum: C++ Dec 31st, 2008 |
| Replies: 5 Views: 819 To give you a clue about what's happening, 100! is about 9.3 by 10^157. To represent that, a 525 bit integer is needed (and that increases 530 bits to represent 101!). 64 bit is nowhere near... |
Forum: C++ Dec 30th, 2008 |
| Replies: 6 Views: 362 You need to be careful with executable compression. Compressed executables have some characteristics associated with self-modifying code (the decompression stub unpacks code and data into memory). ... |
Forum: C++ Dec 27th, 2008 |
| Replies: 8 Views: 492 It doesn't matter where you do it, as long as you obey the one-definition rule (ODR). Typical projects link together object multiple object files to create an executable, and each object file is... |
Forum: C++ Dec 17th, 2008 |
| Replies: 6 Views: 1,314 The only way in which a constructor can report an error is by throwing an exception.
The C++ standard has this to say (in Section 15.2 "Constructors and destructors" which is within Section 15... |
Forum: C++ Dec 15th, 2008 |
| Replies: 4 Views: 496 That statement is inaccurate on so many levels that I'm speechless. Non-virtual functions can also be overridden, but the behaviour differs from overridden virtual functions due to "name hiding", as... |
Forum: C++ Oct 31st, 2008 |
| Replies: 9 Views: 982 Dogma (n) : A firmly held belief based on faith, and often stated as fact. |
Forum: C++ Oct 30th, 2008 |
| Replies: 4 Views: 452 If there are common things that all classes which handle triangles have to do, put those functions into their own class (eg TriangleModelFile derived from ModelFile). Derive the specific/multiple... |
Forum: C++ Oct 25th, 2008 |
| Replies: 8 Views: 1,274 The array declaration int a[n]; is not valid C++. Your compiler doesn't complain because it supports this as an extension. (Your compiler might also support the 1999 C standard (where such things... |
Forum: C++ Sep 28th, 2008 |
| Replies: 24 Views: 2,974 Start with T(0) = 1.
In a loop use the fact that T(n+1) = x*T(n)/(n+1) to compute each term. Add the terms together. |
Forum: C++ Sep 28th, 2008 |
| Replies: 24 Views: 2,974 Oh, please! Huge integer libraries or strings are needed for some things, but falling back on them for basic problems like this is crazy.
The program can go to much higher terms simply using the... |
Forum: C++ Sep 15th, 2008 |
| Replies: 14 Views: 1,142 The above is common practice, but it is easily broken. Imagine, for example, a class that supports its own operator&() - it will not perform as you intend.
Generally, it is better to code in a... |
Forum: C++ Sep 12th, 2008 |
| Replies: 6 Views: 826 Not even close.
You have declared myclass's length() method as taking one argument, and yourlen() calls it with two arguments.
Similarly, yourlen() is declared with no arguments, but when you... |
Forum: C++ Sep 5th, 2008 |
| Replies: 5 Views: 983 You're asking the wrong question. The compiler will attempt to invoke a copy constructor (assuming one exists) upon any attempt to create a copy of an object.
The real practical concern is... |