- Strength to Increase Rep
- +9
- Strength to Decrease Rep
- -2
- Upvotes Received
- 63
- Posts with Upvotes
- 49
- Upvoting Members
- 32
- Downvotes Received
- 4
- Posts with Downvotes
- 3
- Downvoting Members
- 4
- Interests
- Algorithm development
- PC Specs
- Ubuntu and RHEL
164 Posted Topics
Re: There is actually a very simple solution to this problem. First, you are trying to do two things here: [icode] 1. Split an input number into separate digits. 2. Add the digits together. [/icode] First of all, I would not recommend putting your input into an int type. If you … | |
Re: The basic problem with detecting bodies is the inconsistency of orientation. You'll notice that the Face detector is really only good at detecting faces that are pointed more or less toward the camera, and the detector does not find rotated faces well. This is because it is looking for similar … | |
Re: [QUOTE=kumar2884;1132180] But if we need to create a application for a particular device like mobile or digital camera we need to write in C or C++ with out using this libraries and it will take 100 to 200 likes depending up on our requirements is it right ? So all … | |
I am having some trouble getting some overloaded operators working correctly with a simple inherited Vector class (numerical vector, not container) The scalar multiply from the base class doesn't appear to be visible to the derived class. Code follows: Base Class Header [code=c++]#pragma once #include <vector> class Base { protected: … | |
Re: I'm a huge fan of Qt. I build a lot of Qt applications, and I'm really happy with this GUI. Trolltech, the makers of Qt, also provide a full-featured integrated IDE called [URL="http://qt.nokia.com/products/developer-tools/developer-tools"]QtCreator[/URL] that I actually use for my general purpose c++ coding. Qt is very flexible, has tons of … | |
Re: I haven't used them before, but I know a lot of people use [URL="http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation"]quaternions[/URL] to calculate 3 axis rotations. Apparently they compose better than using Euler angles. Have a look. Like I said, I haven't used them, but they might be what you are looking for. | |
Re: What it appears to me is that you have a specialized base-5 numbering system. It is specialized in that it has rules that dictate how you count down in this system. You could make this system very extensible and have it work with an arbitrary number of digits and arbitrary … | |
Re: You have a few problems: 1. This is a recusion problem, but you are not recursing correctly: [code] int g_c_d(int a,int b) { int c; c=abs(b-a); cout<<a<<" "<<b<<" "<<c<<endl;/*put this in to check it was going ok*/ if(c==0){return a;} if(b>a){b=a;} a=c; g_c_d(a,b); [B][COLOR="Red"]// This value should be returned[/COLOR][/B] }[/code] 2. … | |
Re: [QUOTE=LordNemrod;1326996]Die::Die() //Initializes Face data member { Face = 1,2,3,4,5,6; } I am not sure what you wanted to achieve by this, but this assigns 6 to Face. The operator comma works like this - it evaluates all of its arguments from left to right then returns the rightmost argument, in … | |
Re: [QUOTE=nizbit;1320079]I'm trying to find duplicates in an array and removing them by shifting the array index using the same array. I can't figure out where in my code the problem is but I'm still getting a duplicate. Could someone please help pinpoint the problem? I've tried debugging it but I'm … | |
![]() | Re: This is unnecessary code: [CODE] bool Candidate::operator ==(const Candidate& right) const { //return (firstName == right.firstName && lastName == right.lastName); // Rather than the above, I used this... return (static_cast<Person>(*this) == static_cast<Person>(right)); } [/CODE] If you do not define this operator in your derived Candidate class, the operator function from … |
Re: I think the best way to achieve this is to wrap the functionality of a bitset with custom functions. So, to extend your bitset: [code] class TryBits { // whatever other functionality public: extend( const string& ns ) { // insert a check for ns to be a valid bit … | |
Re: [QUOTE=Fbody;1319894]On this site, a "space" or 2 is sufficient indent. A [I]TAB[/I] is too big.[/QUOTE] Actually, you shouldn't have actual tabs in your code. That is my opinion, and it is right. Code editors use monospace fonts ( at least they should, for the love of Turing ). Tabs are … | |
Re: [QUOTE=tennis;1320858]say iter1 and iter2 are both iterators [CODE]*iter1++=*iter2++;[/CODE] what does this line means? Can anybody help explain? ++ and * which is done first? thanks[/QUOTE] [URL="http://www.cppreference.com/wiki/operator_precedence"]Here's a page that will be very helpful![/URL] Operator precedence in c++ is important, but I prefer explicit code to implicit trickery. Parentheses are your … | |
Re: Yes, this code is broken. First, receive is not declared in the main function. You must first declare an object of type [B]bank[/B]. Secondly, you won't be able to use strcpy to write data directly into the c-string bank::receive unless you make a dangerous assumption. Most compilers place the private … | |
Re: **oh and i am using dev-c++ so i cant use strings** You should really consider using something besides dev-c++. Code::Blocks is a common suggestion. You should also know that dev-c++ isn't a language or a standard, so, aside from convenience for the classroom, it has no crucial place in the … | |
Re: Hrmmmmmmm... 1. Why do you need a [I]screenshot[/I]????? I really have to wonder why you would need a screenshot of a running application. I bet it has something to do with my second question: 2. Is this a homework assignment? This is the time of year when computer science classes … | |
Re: [QUOTE=Narue;1317680][B]>So in my view, I'm still right[/B] ...[/QUOTE] Righteous indignation is as heavy a cross to bear as defending an invalid thesis. @Mike She got you. You should at least admit it. @Narue You may be right, but I don't completely agree. One of the benefits of using pure virtual … | |
Re: @Narue Because of perverse curiosity, I must know. When and why have you used placement new before? Perhaps a hardware interface? | |
Re: [QUOTE=tayyab569;1317718]#include <iostream.h> #include <conio.h> void main(void) { clrscr(); int i,p; for(i=1;i<=300;i=i+1) { for(p=2;p<i;p=p+1) { if(i%p==0) break; else continue; } if(i==p) cout<<" Prime:"<<p; } getch(); }[/QUOTE] [COLOR="Red"]What the #&&$*% is this?[/COLOR] [B]1. [iCODE]void main()[/iCODE] is a great way to start fail code[/B] Please, for the love of any deity, use int … | |
Re: This should work: [code] int s = b.Activate(war.get_tp(), damage, 50); //prototype int Activate ( [B]const[/B] int &tp, int weaponDamage, int attack ); [/code] | |
Re: I wouldn't use getline for this. If you do so, you must take responsibility for tokenizing the lines and converting string data. The iostream library can do this automatically for you, so using ifstream and the >> operator is correct. My guess is that you are reading all of the … | |
Re: [code] void randnum(double lower, double upper, int n) // Generate 'n' random numbers uniformly distributed { // between lower and upper limits. double a = 0; double b = 0; srand((unsigned)time(0)); for (int i = 1; i < n+1; ++i) { a = rand(); b = lower + (a / … | |
Re: This definitely sounds like a job for a class not a struct. I'm surprised at the mixture of the STL with a struct that requires specific functionality. Is this an assignment for a class? If so, I wonder why your teacher isn't asking for a class with overloaded operators. | |
Re: Understanding pointers is [I][B]CRITICAL[/B][/I] to mastering C and C++. You should really go out onto the internet and read about pointers. You should work through some tutorials and examples. There is a lot of core concepts in pointer management. I don't think it would be appropriate to discuss it all … | |
Re: You could use the strcpy() function to acquire this functionality: [quote][code] int i; for(i = 0; i < length; i++) { strng[i] = str[i]; } [/code][/quote] | |
Re: This should work. Your function's definition matches your function's declaration. Your function's call matches both. Dev C++ causes problems and has compatability issues. Basically, it sucks and doesn't work well with established standards. You should consider getting a new IDE and compiler toolchain. I've heard that [URL="http://www.codeblocks.org/"]Code::Blocks[/URL] is a nice … | |
Re: [QUOTE=Nathaniel10;1311293]Thank you very much for your suggestions, Vijayan. I hadn't thought that having different classes for different exceptions was an appropriate formulation.[/QUOTE] I respectfully disagree. I believe that different exception types should have different class definitions. This paradigm is used extensively in many C++ libraries. I do agree that you … | |
Re: [QUOTE=mike42intn;1310686] [CODE] char sentance[40]; int i = 0; srand((unsigned)time(NULL)); for( i = 0; i <= 20; i++) { strcat_s(sentance, article[rand()%5]); strcat_s(sentance,noun[rand()%5]); strcat_s(sentance,verb[rand()%5]); strcat_s(sentance,preposition[rand()%5]); strcat_s(sentance,article[rand()%5]); printf("\n\n%s\n\n'", sentance); } } [/CODE][/QUOTE] My guess is that you are overrunning your sentence array. First, you should make it larger. 40 characters probably won't consistently … | |
Re: You really need to post code demonstrating your problem. We have good imaginations, but this is a little sparse.... | |
Re: [QUOTE=Rez11;1310778]Does it look clean?[/QUOTE] The code is actually pretty clean for a beginner! +1 for you. There are a few things you could do to improve it further. 1. Put the score input and score display sections in their own functions. It is always preferable to keep the main function … | |
Re: The purpose of homework is to learn how to solve problems similar to the ones you will face in your career. You must try to do your own homework. When you have struggled through some code and feel hopelessly stuck, post [B]specifically[/B] what you are trying to do with your … | |
Re: [QUOTE=samsons17;1309471]Hi guys.... [CODE] if((number[i][j])%2==0){ [/code][/QUOTE] This is where your program goes wrong. You are testing whether the [B]value[/B] of the "matrix" at i,j is even or odd. Since you haven't initialized any of your values in the array, this will produce undefined behavior. When you allocate memory for an array … | |
Re: [QUOTE=sDanyal;969758]This is a incomplete code Complete this code by using Dev C++ for practice[/QUOTE] Don't post complete code for this. I'm almost certain this person wants you to do his homework for him. Asking for the code to be completed "by using Dev C++" is almost a certain give-away. No … | |
Re: You could do this in an even cleaner fashion by using references. If you use const references, you can pass in values that have not been saved in a variable: [code] #include <iostream> #include <vector> using namespace std; const double& max( const double& a, const double& b ) { return … | |
Re: My friend, you are suffering through pointer hell. The best way to avoid this is to use the standard template library. Vectors are infinitely nicer than dynamically allocated arrays of pointers. In order to understand your code, I had to work through it. In the process, i utilized the standard … | |
Re: Readability >>> clever tricks This code is painful: [CODE] ostream & operator << (ostream &out, const std::vector<beamlet> &b) std::ostream out1,out2; for (b::const_iterator it=b.begin();it!=b.end();++b){ if (it!=b.end()-2) out1 << it.left << "," << it.right << ",\n"; else out2 << it.left << "," << it.right << "\n"; out << out1 << out2; return … | |
Re: Your solution is not recursive. Recursive logic is very elegant and powerful, and for algorithm junkies like myself, completely awesome. The trick is understanding how recursion works. I'll use your reverse problem as an example. Suppose we want to reverse the string "Hello". Well, the fundamental problem is switching the … | |
Re: First of all, you should post the code for your classes so we can see the underlying logic. Secondly, you really don't need to do any casting here. Because the generate() function (I assume) is a virtual member of your base class, you should be able to call ptr->generate() with … | |
Re: When you run your program from the command line, redirect stderr to a file: [icode] $ myprogram 2> log.txt [/icode] | |
I notice that there are many, many threads where posters receive few if any comments. When I open these threads, it is usually obvious right away why no one has bothered to reply. The problems with these posts vary from deliberate solicitation for homework solutions to poorly composed questions. I … | |
Re: The problem here is that you are declaring an instance of a variable inside of your header file. You are essentially making [B]messages[/B] or [B]channels[/B] global variables. This would be fine [I]if the header was only included by a single source file[/I]. Here's what's happening. Every source file that includes … | |
Re: [quote=sonsofliberty84]i guess all you need is to place each input in an array and then do a bubble sort on that array, then output the first and last values.[/quote] There are two huge problems with your approach. First, your solution is doing way more than is necessary. If I was … | |
Re: As a fanboy of Qt, I recommend you research it a little. It's a very powerful cross platform GUI based on c++. Any programs you write using the Qt API can be built on windows, mac, and linux ( among others ). While drawing shapes in a QGraphicsView is not … | |
Re: Are you macro protecting your header files? [code=c++] #ifndef _SOME_HEADER #define _SOME_HEADER class SomeClass{...}; #endif [/code] or [code=c++] #pragma once class SomeClass{...}; [/code] | |
Re: [QUOTE=Codname47;1270524][CODE] myLinkedList ( ) { //TESTED head = NULL; last = NULL; cout<<"Linked List is created with default constructor\n"; } myLinkedList ( myLinkedList &arr) { //TESTED if (arr.head == NULL){head=NULL; last=NULL;} else{ head = NULL; last = NULL; temp2 = new node; temp2 = arr.head; while(temp2!=NULL){ insertLast(temp2->item); temp2 = temp2->next; … | |
Re: Here's a litte bit of code that will help with your string/number conversion: [code] #include <string> #include <iostream> #include <sstream> #include <iomanip> /** Converts a number to a string * @param number - The number to convert * @param prec - Floating point precision to use * @param w - … | |
Re: The first problem is in your class definition. The scope operator` ( :: ) `is only used when your class is declared in one place (like a .h header file) and the functions are defined in another place (like a .cpp source file). When you are declaring and defining a … | |
Re: Could you please post your header files for the Controller and Menu class? | |
Re: Read this: [url]http://www.daniweb.com/forums/thread78223.html[/url] You need to show that you have tried to come up with a solution first. Also, why, oh, why is this posted as a poll? |
The End.