1,177 Posted Topics
Re: Which operating system are you using? Which IDE are you using (visual studio, KDevelop, etc)? | |
Re: And if you're going to cut and paste a whole assignment, at least make the the formatting is not all wacky! Also, you don't seem to be asking for project ideas, but rather how to do a specific assignment! | |
Is it just me? Or has everyone a drastic slow down in recent days? David | |
Can anyone explain why this doesn't work? [code] #include <iostream> class Parent { public: virtual int Add(int a, int b) = 0; int Add(int a) { return this->Add(a,a); } }; class Child : public Parent { public: int Add(int a, int b) { return a+b; } }; int main() { … | |
Re: I am also confused and don't know what to do... haha. Can you post the problematic code? It is probably going to be hard for us to debug without access to a big cluster. | |
Re: Can you please post the code that is generating this error? | |
Re: And as far as lay-people are concerned, Ubuntu IS Linux. You can't just install Linux, you have to install one of its varieties (Ubuntu, Fedora, etc). | |
Re: Is this a compiler error? It seems to be related to your development environment more so than your code... | |
Re: You can use the STL set (#include <set>). [url]http://www.cplusplus.com/reference/stl/set/[/url] For union, just add all of the elements to the set and it will take care of removing duplicates. | |
Re: 'std::out_of_range' means you are accessing an element of the vector that does not exist. Here is my suggestion. If the input is working properly, then hardcode some values for the input. Then post the shortest compilable code that demonstrates the problem (hopefully < 20 lines). This makes it very easy … | |
Re: Can you post some compilable code (i.e. which headers are you using?) Have you output the value of GetTickCount() before and after the algorithm? | |
Re: Welcome to DaniWeb! First please use more descriptive thread titles :) Second, that is pretty much a signal processing question - not really a c++ one. If you find an algorithm and try to implement it in c++ and have trouble, then we may be able to help. I would … | |
Re: I don't know about this stdafx business, but from what my compiler tells me you need cstdio to use printf (but you should use std::cout instead). Also, strcat_s is not necessary, just use std::string and the '+' operator. I would even store the words originally in a std::vector<std::string>. I also … | |
Re: Don't forget to close your code tag :) First, there is no reason to use global variables here. It is just a bad habit that will bite you at some point. Second, you are asking it to read 'a' lines (477). The example data you posted is only a few … | |
Re: Can you give us an example piece of code as well as the output you are getting and the output you expect? | |
Re: Please use real words. 'plssss' and 'tnx' are not words! It helps to keep the community looking professional. | |
Re: Please post a significant attempt and we can try to help if you get stuck. If you don't want to do your assignment, why should we?? Also, please use a much more descriptive thread title. | |
Re: Please post a significant attempt and we can try to help if you get stuck. | |
Re: First I would be really careful about calling a variable 'size'. It could definitely clash with other things. Let me recommend that you add comments to the major portions of your code. This will not only help us read what is going on in your code, but I bet once … | |
I am trying to remove the need to #include stl elements in my header (a requirement for a project I work on). I wrote a "wrapper" for std::vector called "MyVector". I declare a pointer to a MyVector as a member of MyClass. Then when I try to use this in … | |
Re: I would suggest making a demo program to make sure you understand how stringstream works before using it in your program with user input. If you hard code values and it works as you'd expect, then you know the problem is with the input itself. | |
Re: Hi Mike - welcome to DaniWeb! Can you detail the problem more for us? What is wrong? Are there are any compiler errors? Give an example input, the current output, and the expected output. Looking at this code: [code] Rational obj1,obj2,obj3; { obj1 = numerator,denominator; obj2 = numerator,denominator; obj3 = … | |
Re: What language/database system is this? Please provide a compilable example of what you are trying to do and maybe someone will be able to get it to work for you. David | |
Re: Try looking up "function pointers". Does this example help? [url]http://programmingexamples.net/index.php?title=CPP/FunctionPointer[/url] David | |
Re: My suggestion is to first create a demo program where there is no user input (hardcode or remove anything that you can to still reproduce the problem). This way we all know exactly what the state of the program is when looking at your code. David | |
Re: [url]http://programmingexamples.net/index.php?title=CPP/Strings/Compare[/url] | |
Re: What have you tried so far? If you post some code and tell us what is wrong with it we may be able to help. David | |
Re: Is this a "clever" trick to get us to do your assignment? This should only be like 3 lines, right? | |
Re: Also, please use code tags when posting code. | |
I posted a while back about how to overload << It seems all the examples online have the second argument as const, ie [code] ostream & operator << (ostream &output, const Point &p); [/code] but if I have a member function that simply returns a double [code] double Point::getX() { … | |
Re: Why don't you just write another program to replace the "show desktop" program, and have your program do whatever it wants to and then call the real "show desktop"? | |
Re: I recommend you use an std::string instead of a character array for m_name and Name. | |
Re: hanvyj In cases like this, I'd suggest making a short, compilable program outside of the context of your big program. [code] #include <iostream> int main() { long myLong = 20.3; std::cout << myLong << " " << (int)myLong << " " << int(myLong) << " " << static_cast<int>(myLong) << std::endl; … | |
Re: Another vote for using std::vector instead of an array. It will save you countless headaches. | |
Re: Welcome to DaniWeb! First, please use real English words. E.g "plz" is not a word. Second, please tell us what is wrong? What is the input? What is the current output? What is the expected output? Are there any compiler errors? These things will help us help you as efficiently … | |
Re: Welcome to DaniWeb! (Please use code tags when posting code, it makes it much easier for us to read :) ) What you have there looks good. To add a second variable, simply do this: [code] int incr10(int& num, int& var2) [/code] You didn't specify what this second variable is … | |
Re: I would step back for a second and ask why you are writing your own bitmap writing function? I bet there are bunches of libraries that include such a thing. Then you can spend your time writing new code! | |
Re: Why did he make it complicated? It looks pretty reasonable to me. | |
Re: I think you are supposed to use reinterpret_cast for this, but it doesn't work (surely I'm doing something wrong) [code] #include <iostream> int main () { float f = 2; unsigned char* c = reinterpret_cast<unsigned char*>(&f); std::cout << (int)*c << std::endl; return 0; } [/code] It outputs 0 when I … | |
Re: You'll have to make sure you set GAMEOVER to false before you start the loop. Also, the loop doesn't stop as soon as game over is set to true. For example [code] while(!gameover) { //some stuff gameover = true; //more stuff } [/code] In that example, more stuff will be … | |
Re: That garbage value is most likely caused by an uninitialized variable. Any time I see '**': [code] neuron** connections; [/code] I cringe... Have you considered using: [code] std::vector<std::vector<neuron> > connections; [/code] instead? | |
Re: You can also use find() to check your results: [url]http://programmingexamples.net/index.php?title=CPP/STL/Set[/url] The loop would be something like [code] while(!found) { if(currentItem() != searchElement) { next(); } } [/code] Once you've given it a shot let us know and we can help you if you get stuck. David | |
Re: I'd suggest trying to hardcode the values to see if there is something wrong with your input. I'd also suggest using <string> instead of <string.h> This works fine for me: [code] #include<iostream> #include<string> int main(int argc ,char* argv[]) { std::string line1 = "Test 12345 Test 6789"; std::cout << line1 << … | |
Re: I would suggest writing a CSV (comma separated value) file. Excel will then be able to import this. David | |
Re: Why not use a vector of vectors? Something like this: [url]http://programmingexamples.net/index.php?title=CPP/2DVector[/url] but rather than initialize it like this: [code] std::vector<std::vector<int> > items ( 5, std::vector<int> ( 5 ) ); [/code] simply do: [code] std::vector<std::vector<int> > items; std::vector<int> row1; //construct row1 however you want and as long as it needs to … | |
Re: The title says "Matlab/c++ programming question". I see the Matlab... but where is the c++? This question seems better for this forum: [url]http://www.mathworks.com/matlabcentral/newsreader/[/url] David | |
Re: Andreas5, Please use an informative title for your threads. This will attract the correct set of readers. David | |
Re: Seems like a simple for loop should do the trick, no? Show us what you've tried and we can help if you get stuck. David |
The End.