6,741 Posted Topics
A fairly complete implementation to provide another perspective on a seemingly simple program. | |
This code demonstrates AVL insertion and deletion. The code was originally written in C by myself a little while back for a tutorial. The translation to Java was fairly trivial, and to add a little excitement I even threw in a few generics. Yes, I'm aware of this line: tree.data … | |
Insertion sort, Selection sort, Bubble sort, Shell sort, Quicksort, and Heapsot. All optimized and ready to be experimented with. This is the framework for a Java application that speed tests various sorting algorithms (because there's usually little need to write one's own in production programs). Several popular algorithms were left … | |
This quicksort implements the basic recursive algorithm with three improvements. The first improvement is choosing the pivot based on the median of three values in the list to be sorted. This minimizes the chances of a worst case scenario. The second improvement speeds up the algorithm by termination when subfiles … | |
Re: [B]>I feel quite insulted and angry about your comments.[/B] Grow thicker skin. Nobody cares how you feel, nobody cares what your situation is, and everyone will take you at face value. If you look like a leech, you'll be treated like a leech. However, that said I think yellowSnow and … | |
Re: The C# and C++ IDEs are written by separate teams and do not correspond in supported features. In other words, if you can't find that feature in the same place as you would find it for the C# IDE, you're SOL. However, you can still do a selection format by … | |
Re: [B]>Associativity? I don't even think you got that right if you were trying to say precedence.[/B] Nope. He got it right, but came to the wrong conclusion. ++ and * (dereference) have the same precedence but are right associative, so ++ is indeed performed first. However, one can't forget that … | |
Re: [B]>I'm relatively comfortable with C++ and am taking a class in C for the >first time. I'm finding it difficult and frustrating to adapt to the new >language. It's kind of like trying to box with a hand tied behind my back.[/B] If you're used to C++ and the benefits … | |
Re: >i just am not sure how accurate it is as anybody can edit it. Tutorials aren't any better because you're not sure if the author can rub two brain cells together. You have to assume that it's accurate, or find multiple sources and compare. | |
Re: [B]>My goal is to "master" C++.[/B] That's a nice goal, but don't plan on actually attaining it. I doubt there's anyone in the world who's mastered C++. There's just too much involved, too many nuances. But you can certainly be a C++ badass. That's more than possible given a decade … | |
Re: [B]>i wanna know as mentioned before the c language is dying[/B] Total BS, but also keep in mind that C is not C++. Neither are dying (or are likely to die in your lifetime). [B]>should i stop and learn something else before its too late.?[/B] If you want to stop … | |
Re: What's wrong with this picture: <J. Random Newbie says>: "Daniweb is a big and good community, but I want you to cater to my whims and add a forum each time I start learning something new because I'm the most important person in the universe. If you do that I'll … | |
Re: [code=cplusplus] #include <ios> #include <sstream> stringstream convert ( abc ); convert>> std::hex >> i; [/code] | |
Re: As much as we'd love to help you cheat (not really), piss off. We help people who are willing to put in some effort, not people looking for a quick and easy answer. | |
Re: There seems to be no program yet, so there's nothing to help with. Best of luck to you. | |
Re: Just out of curiosity, why are you trying to circumvent the access mechanism? Those members are private for a reason, and if you need to access them from outside of the class without a field, something isn't right. However, if you really want to use a pointer to a member, … | |
Re: [B]>However I could [I][not][/I] give precise details of the internal implementation >of the table or say how to access it from client code, so I failed the question.[/B] Then the question itself is invalid. The exact implementation of the vtable mechanism is compiler-specific and how to access it from client … | |
Re: I'd bet my paycheck that most of the big names haven't. | |
Re: >Try-- >srand( time(NULL) ); How is that supposed to fix the incompatibility of time's return value with srand's parameter? By the way, 0 and NULL are identical in C++. >try using time without ctime Then the declaration would be missing. >ctime has a function called time_t time ( time_t * … | |
Re: >Would it make sense to add a new forum to separate it? Frankly, I don't think it makes sense. But if it did then it would also make sense to add a new forum for C++/CLI, and for Qt because it seems to be a favorite recommendation for pretty pictures, … | |
Re: >C How to Program >C++ How to Program I suppose if you have two C-notes burning a hole in your pocket, you could get those two (last I checked, they were both over $100). Personally, I'm not willing to pay more for two beginner's texts than I did for the … | |
Re: When the hoops you have to jump through to get this kind of behavior through the library are both advanced and somewhat obscure, one wonders what's so hard about manually writing to fout each time you write to cout (or calling a function that does it for you)... | |
Re: >So is 'some admin chap' going to tell us why Narue left So as not to hurt any feelings, I'll simply say that I've lost interest in Daniweb and the details are personal. My activity has slipped in the last several months (to the point where for the last two … | |
Re: I'd recommend Canaan as well. From the first two episodes, it's excellent. | |
Re: >Does anyone else have any comments? It looks a lot like you completely dismissed peter's comments because they didn't sing your praises. That's not exactly going to encourage more people to waste their time on your frail ego. :icon_rolleyes: | |
Re: It looks like you're all turned around. Usually people write utilities to fulfill a need. You're looking for a problem to solve, which means you don't need a utility and wouldn't use it even if you decided what to write. | |
You are cordially invited to the [B]#daniweb[/B] channel on server [B]irc.daniweb.com[/B], port [B]6667[/B]. We need some new blood to keep the conversations fresh, and what's more fun than chatting with your favorite techies in real-time? | |
Re: [B]>Is computer programming worth it?[/B] Yes. Programming is one of the few fields where you can flex your creativity and not starve. Besides, I'd much rather be constantly learning than get into a monotonous rut because my skillset doesn't need to evolve. [B]>employers in California are now asking for 4 … | |
Re: [B]>When printing output to a terminal in C++, should i use "\n", or "endl"???[/B] I recommend using '\n'. For the most part, the stream is flushed in the right places by default, so explicitly flushing it yourself is just an extra unnecessary step. [B]>Is one lighter, faster, or industry standard?[/B] … | |
Re: >at the end of the code just write >getch(); And also include <conio.h>, not forgetting that the conio library functions are absolutely non-standard and your code won't work on many compilers. >then you can only exit the output after pressing ne character. Is it really [B]that[/B] much work to type … | |
Re: [B]>Incr.Add(1);[/B] You use the arrow operator to access members of managed references: [code=cplusplus] Incr->Add(1); [/code] | |
![]() | Re: Ethical or not, we don't answer questions about how to hack. It's against Daniweb's rules. |
Re: >they are required to have different argument lists Or constness for member functions. The following introduces no ambiguity yet the return types and argument lists for the overloaded function are identical: [code] #include <iostream> using std::cout; using std::endl; class test { public: void f() { cout<<"f()"<<endl; } void f() const … | |
Re: [B]>If you don't know it by then, you're too late[/B] Not true. All you need to do is find a bored hacker and you can acquire a program like this: [code=cplusplus] #include <cctype> #include <cstdlib> #include <ctime> #include <fstream> #include <iostream> #include <map> #include <string> #include <vector> namespace { typedef … | |
Re: [B]>do you advice me to continue with K&R or get another book to continue with ?[/B] If you can handle K&R, I'd recommend going with it as your first weapon. If you can't handle K&R, I always liked "Pointers on C" by Kenneth Reek. I believe it's out of print … | |
Re: Read up on dynamic_cast. It does what you're asking for (keeping in mind that adding new shapes won't be as simple as creating new polymorphic classes), though I'm sure some OOP nazi will wander in and give you an overly complicated design pattern that will also solve the problem. :icon_rolleyes: | |
Re: Did you do any research before posting here? What did you find and why wasn't it sufficient? | |
Re: The STL doesn't encourage or discourage inheritance. Why don't you ask a more detailed question? | |
Re: On current implementations, you'll probably find that the stdio library is faster than the iostream library. The usual recommendation is to try both and use the one that's fastest on your setup, if all you care about is execution performance. | |
Re: MFC is a library of classes that wrap the Win32 API and make it more convenient to write applications. The .NET framework is a more complete abstraction into a managed environment (rather than a wrapper for a lower level API). | |
Re: This is a case where you can probably get away with overwriting rather than rewriting. Search for your friend's name, then step forward over the whitespace and simply write the new phone number: [code=c] /* Warning: this code was written without the aid of a compiler */ #include <stdio.h> #include … | |
Re: Just pass the limit of the stream size type: [code=cplusplus] #include <istream> #include <ios> #include <limits> in.ignore ( numeric_limits<streamsize>::max(), delim ); [/code] | |
Re: Are you running in the debugger and it's stopping automatically? Or are you stepping through your code and getting this message when you try to step into the function? Your error sounds a lot like missing debug information during the build, not a problem with the code itself. Does the … | |
Re: Books don't make you a better programmer, practice makes you a better programmer. | |
Re: When starting out, it helps to always use braces for compound statements. Your loop should look like this: [code=cpluplus] while ( x < y ) { x = x + 1; cout<< x <<'\n'; } [/code] If you don't have the braces, only the first statement will be the whole … | |
Re: When you turn on your computer, it does a bunch of stuff, right? POST, loading the OS, logging you in, starting up automatic programs, etc... Constructors have a similar purpose in that they put your objects into an initial ready state. Achieving that state would be cumbersome at best (because … | |
Re: [B]>_getch() isn't part of the C++ standard[/B] There's not a portable way to do what the OP wants, so any viable solution will use things that aren't part of the standard. [B]>you can't backspace[/B] That's an easy addition. [B]>and you're using conio.h[/B] See my comment for getch. So far you … |
The End.