1,177 Posted Topics
Re: I think you need to display the plot in a separate thread. This operation will vary from OS to OS. | |
I don't understand why can you do this: [code] Employee *emp; if (condition1) emp = new Employee(); else if (condition2) emp = new Manager(); [/code] but not this: [code] Employee emp; if (condition1) emp = Employee(); else if (condition2) { emp = Manager(); [/code] Maybe this is a TERRIBLE idea, … | |
Re: I realize this is quite an odd/complicated problem, but can you reduce the amount of code necessary to produce it? Maybe you can play around and remove as many lines as possible and still produce the error. Often that will help you isolate the bug yourself, or if not, then … | |
I'm trying to start writing tests for all of my functions as per Test Driven Development. My question is, say I construct a test for "rotate vector". It would be something like this: [code] int TestRotateVector(const Vector &V) { Vector Original(1.0, 2.0); Vector Rotated = Original.Rotate(10); //rotate 10 degrees if(Rotated … | |
Re: You clearly have not read any of the forum rules... | |
Re: The getSales() function shouldn't be void - it needs to return the sales! | |
Re: I don't understand, you are saying if it equals zero then "it is not a number"? Also, you can use this [icode]std::string Zero = "0";[/icode] then [icode] if(Zero.compare(buf))[/icode] actually, i think compare() returns the edit distance, so you need to see if it equals 0, so more like [icode] if(Zero.compare(buf) … | |
Re: Can you extract the problem into ~ 20 lines? Maybe make a hard coded name/date/account and then just call the function that is returning the wrong value? | |
Re: Please use code tags and post the smallest fully compilable example that demonstrates the problem. | |
Re: Shivi, it may also be easier to post the very smallest compilable example that produces an error directly on the forum using 'code' tags rather than creating an attachment. This way some users can potentially see the problem right away without having to download anything. | |
Re: What is it supposed to do. Maybe you can give sample input, current (incorrect) output, and expected output. | |
Re: you should use code=cplusplus rather than code=cpp because that doesn't work! also, if you don't have / know how to use a debugger, then you should do "printf debugging" which means outputting text so you can tell where the program crashes. That will probably help you find the segfault. | |
Re: First, that is a linker error - it seems you have not defined ProcessChoice(int) in an appropriate place. Also, surely 99% of those lines of code have nothing to do with the problem. Pare down the code to about 20 lines that produces the same problem and then we can … | |
i.e. [code] class A { int x = 5; }; [/code] I saw a mailing list post from October 08 where a guy asked if this was going to be added. gcc 4.4 was released April 09, so I would assume it would have been added by then? I haven't … | |
Re: It doesn't sound like the problem has anything to do with tic-tac-toe. Can you please make a much, much smaller demonstration of your problem along with input, expected output, and current (incorrect) output. | |
Re: You could use std::vector's of std::vector's - then you don't have to worry about new() and delete(). | |
Re: It looks like you have not defined the type/class 'X'. | |
Re: Surely the source code is not 18MB, try deleting the files that Ancient Dragon mentioned. | |
Re: You are correct that in standard c++ you cannot overload a function by return type alone. | |
| |
Re: the compare() function is just like "==" for std::strings. | |
Re: I often zero pad things like this: [code] std::string ZeroPad(const char num, const unsigned int rep) { std::stringstream Filled; Filled << std::setfill('0') << std::setw(rep) << num; return Filled.str(); } [/code] but maybe inserting a '0' like MosaicFuneral said is more appropriate in this case? | |
Re: And, clearly, if you're having a hard time with anything in particular, ask us here! | |
Re: 1) put your code in "code" tags 2) compile it yourself and report any errors! | |
If I do something like this: [code] print "%08d" % 2 [/code] It will print '00000002'. However, I want to change the "8" to a "3" at runtime (to get '002' instead). I tried this: [code] MyLength = 3 print "%0" + str(MyLength) + "d" % 2 [/code] but I … | |
Re: Please make the title of your thread informative - e.g. "Opening a cdrom drive". | |
Re: Please wrap your code in "code" tags. Also, please give us a sample input, the current output, and the expected output. I don't think you need this: [icode]#include "stdafx.h"[/icode] You should use [icode]#include <cmath>[/icode] instead of [icode]#include <math.h>[/icode] Another rule is that you should pretty much never use [icode]using namespace … | |
Re: also, there should be no "=" in this line: [code] return strcspm(mystring,letter); [/code] also, did you mean for "strcspm" to be "strcpn" ? If so , that lives in cstdio | |
Re: What are you talking about? What is the code supposed to do? Can you give sample input, expected output, and actual output? | |
Re: [code]#include <iostream>[/code] is where you will find cout, etc. namespaces are ways to group functions - for example, the cout, etc you are looking for are in the std namespace, so you have to call them like this: [code] #include <iostream> int main() { std::cout << "something" << std::endl; return … | |
Re: You could use a switch statement instead of an if and a bunch of else ifs - I never really got the difference but it's something for you to fool around with. | |
Re: Why do you want to read a character at a time? Why not use std::getline() to read a line at a time into an std::string? | |
Re: I don't think this is really a c++ question at all, sorry Peter. | |
Re: Are you talking about these functions? [url]http://www.codersource.net/cpp_date_time.html[/url] | |
Re: what is an "academic automation system"? You should probably ask much more specific questions about code that is not working. | |
Re: You can just throw them all into an std::set and then read them out into a vector. It will take care of the duplicates for you. | |
Re: Yea, I think that generally the convention is to not include .cpp files. Surely you can make a project with any IDE. CMake is becoming pretty popular - it is a "crossplatform project building" utility - that is, in linux, you can generate a makefile or a KDevelop project. In … | |
Re: mrniceguy - you're going to have to put in some effort before anyone here will help you. Give it a try and then we can take a look and see where you've gone wrong. | |
Re: Please post the smallest example that you can extract, a sample input, the expected output, and the current output. | |
Re: I believe the preferred method of reading all the lines in a file is this: [code] std::string line; while(getline(fin, line)) { //the current line is now in "line", handle it } [/code] | |
Re: I believe what ithlep means for you to do is [code] MyFrame *mainFrame = new MyFrame(wxT("Test Harness"), wxSize(700, 600) ); if(mainFrame) mainFrame->Show(true); else std::cout << "There was an error creating mainFrame!" << std::endl; [/code] | |
Re: Please provide the smallest possible segment of code that isn't working, along with example input and actual output vs expected output. | |
Re: Thanks for that useful answer William Hemsworth! | |
Re: Where is CString declared? Is it a visual studio thing? Because CString is definitely not a standard c++ thing. | |
Re: Wow, you didn't even take the time to say "I have this assignment, can you help me?" - you just copy and pasted directly!! | |
Re: Sounds like he was asking more about GUI type stuff rather than 3d graphics? In linux, there are a couple of main GUI libraries like QT and GTK. I'm not sure about windows. They usually have some kind of graphical designer that you can layout buttons and textboxes and whatnot, … | |
Re: You could also use an std::vector of your struct to avoid almost every problem that will come up. Dave | |
Re: Please post the smallest version of your code that will produce those linker errors. Then we can see which libraries you are trying to use. Dave | |
Re: Can you abstract the question to something like "how do you input everything the user types until the enter key is pressed?" or something like that? I'd say 3/4 of those lines are not related to your question. Please post 1) the shortest example possible that demonstrates the problem 2) … |
The End.