Type: Posts; User: laserlight
Search took 0.22 seconds.
One of the characteristics of bubble sort is that only adjacent elements are compared. Your first code snippet compares elements that are not adjacent, so it is not bubble sort.
Perhaps we could...
February 9th, 2016, 10:36 AM
You should avoid global variables. In this case, this means that you should move these declarations:
bool goodnum = true;//assume good
from file scope into the local scope of the...
February 8th, 2016, 03:58 PM
Anyway, tomy12, maybe this will help:
allocate should allocate memory for the elements of the vector without actually creating them, i.e., after it is called, you have memory, but technically you...
February 8th, 2016, 03:42 PM
The skeleton of My_allocator does follow the essential member functions of the pre-C++11 standard allocator though, so I think the problem probably lies in the wording, i.e., the instructions were...
February 8th, 2016, 01:41 AM
I note that 2kaud's code example will allow input such as "1abc": the "1" would be read and validated, but as you do not attempt to read the "abc", there is no input failure, so it appears to...
February 4th, 2016, 11:58 AM
What exactly does that mean? Perhaps you should provide example input and expected output.
February 4th, 2016, 04:27 AM
So you managed to implement the code for your original problem using a for loop? I think that's fine in terms of how easy it is to understand and how fast it will be.
February 4th, 2016, 03:55 AM
Have you ever done that exercise where you are given a sequence of values, and you're supposed to display them in rows of say, 3 values per row? You can adapt that idea here.
January 27th, 2016, 03:01 AM
You don't even need to know a programming language like C++ to learn database design, SQL, and MySQL in particular. For example, you could use graphical tools for inspecting a MySQL database and...
January 21st, 2016, 11:54 AM
Oh wait, I just realised that 2kaud's example from post #5 has two template parameters, so Richard.J's "template parameter for the object" comment refers to the second one. My bad. Yeah, it certainly...
January 21st, 2016, 09:39 AM
It would, if the corresponding argument was a std::map<int, Account> object. However, in the example code from post #1, the corresponding arguments may be a std::map<int, Saving> object or a...
January 20th, 2016, 01:08 PM
I don't think that will work though: std::map is a template, and possible arguments include a map<int, Saving> object and a map<int, Current> object.
It also looks like Create should not be a...
January 20th, 2016, 11:00 AM
I think part of the fun is trying this out yourself. I would expect something like this:
int i = 1234;
int width = 10;
/* call sprintf to format format here
January 20th, 2016, 10:41 AM
Yes, e.g., use sprintf to format a string that is then used as the format.
January 19th, 2016, 12:23 AM
Instead of trying to cram many methods into a single interface, consider separating them according, as per the interface segregation principle. Maybe you could have something like this:
January 16th, 2016, 02:06 AM
If you cannot understand a library with available code that was written for your scenario and that was optimised by people who have been researching and experimenting with this much longer than you,...
January 16th, 2016, 01:08 AM
Um, that looks like the beginning of an approach leading to the Karatsuba multiplication algorithm.
I suggest that you go back to trying to get a third party library to work for you, and see if it...
January 15th, 2016, 09:57 PM
Not quite: int has a minimum guaranteed value of -32767 which is only 6 chars, and could have a minimum value that cannot be represented with 11 chars, even though I don't think any implementation...
January 15th, 2016, 02:19 PM
This array of char can only contain a string of a maximum length of 6:
If you want a string of a length of 8, then you need an array of 9 char to account for the null character.
January 13th, 2016, 12:35 AM
The caller will receive a copy of the shared_ptr, hence maintaining the reference count, no?
Incidentally, I think it may be better to return a unique_ptr, hence allowing the caller to opt out of...
January 11th, 2016, 10:40 AM
Have you tried increasing the warning level when compiling? Sikkirigi's examples definitely fall under the "trivial cases" mentioned by superbonzo in post #9, so while there might be debate over...
January 8th, 2016, 09:46 PM
The behaviour is undefined in all the cases that you posted, whether or not you use prefix or postfix operator++. Refer to this FAQ on expressions in C that is applicable to C++. Consequently, there...
January 7th, 2016, 03:55 AM
What is your current code and how does it not work?
January 6th, 2016, 01:11 PM
Why not a C++11+ example?
Anyway, I recommend that you attempt this yourself. I mean, I certainly don't have any "simple banking system example in C++ but with OOPS concept like Inheritance, and...
January 6th, 2016, 05:57 AM
I wonder if you have considered an approach like this instead, using facilities from <algorithm>:
// Partition messages into those that are to be delivered now, and those that are not:
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!