2,045 Posted Topics
Re: Say you had: [code] enum priorities {zero,one,two,three}; priorities mypr; int i = 4; mypr = static_cast<priorities>(i); [/code] What does mypr then mean? There's no value in the enum for 4, so should it be cast to 4? It's saying that this behavior could cause almost any results and should be … | |
Re: [icode]#include <ctime>[/icode] and call [icode] srand((unsigned)time(0)); [/icode] (once) before you call rand(). | |
Re: Either make choice a single character and acquire it by [icode] cin.get(choice);[/icode] (you will need a [icode] cin.ignore() [/icode]after to mop up the '\n' or use [icode] if(strcmp(choice,"Y") ==0) [/icode] instead of your [icode](choice == "Y")[/icode] EDIT: D'OH WaltP beat me to it | |
Re: [icode] while(!input.eof()) [/icode] See [URL="http://www.daniweb.com/forums/post155265-18.html"]this[/URL] about eof. Your function is passing in avg by reference but never doing anything with it. Either return your (S1+S2)/2 calculation and use it as such or make the function void and assign [icode] ave = (S1+S2)/2;[/icode] | |
Re: [quote] I am concerned on how to get the variables directly in the structure [/quote] Can you give an example (or more details) about what this means? | |
Re: This should be an indispensable [URL="http://en.wikipedia.org/wiki/Comparison_of_computer_shells"]reference[/URL] for you. You ought to be able to dig up code for most if not all of them (at least the *nix ones). | |
Re: [code] while (! input.eof()) { // Read names from file using ',' for delimiter? getline(input, Names[rTotal]); input >> Names[rTotal]; input.ignore(); ++rTotal; } [/code] This was overwriting the name you read in with the getline immediately after. You want something like: [code] rTotal = 0; while(getline(input,rTotal)) //uses default delimiter of '\n' … | |
Re: You need to use DateTime.ParseExact() -- [url]http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx[/url] along with the the format specifiers on[URL="http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx"] this[/URL] page. I tried to get it to work but it was fighting me on the GMT specifier. However, if you move the date to right after the month it will match the built in "R" … | |
Re: Part of the problem is you are trying to read a text file in binary mode. In binary mode you need to use read() to get a block of bytes. I can see how it might read some of the chars in that way but there must be some subtlety … | |
Re: [quote]or system("clear"); on *nix computers. [/quote] system is used to run a command of either dos or *nix on the respective system. He was offering you system("cls") on your Windows baed PC or system("clear") for use in *nix if it was applicable. However, AD was also saying that this information … | |
Re: Put in a [icode] cin.ignore(); [/icode] right before your getchar() call. There is probably something left over in the input stream after your getline call (though I think getline should discard the newline but maybe I'm thinking of something else) which is taken in by your getchar ending the first … | |
Re: It couldn't hurt to do a search at the [URL="http://social.msdn.microsoft.com/Forums/en-US/Vsexpressinstall/threads"]VS express editions install forum[/URL]. I don't know the answer to your question but they get asked this kind of thing on a daily basis. | |
Re: [icode] getAverage(array[].4.5) [/icode] is not correct. When passing in a 2D array only the last dimension is needed, so it would be [icode] getAverage(int array[][5])[/icode] in the function definition. Make life easier on yourself and use a nested for loop approach to the averaging function: [code] for (int i = … | |
Re: Start out with something like [URL="http://www.cplusplus.com/doc/tutorial/classes/"]this[/URL] (it has good examples for you). Google any terms you don't know and when you have something you're stuck on, post back. | |
Re: Change line 11 to: [icode]string get() const //get name [/icode]. I think it stems from the nature of the strings once they enter in the map (since they become keys) but I am not sure. | |
Re: You don't need to use rand/srand if you do what AD showed you. The algorithm takes care of that for itself. If you want to use the approach you propose there, just do [icode] i = rand() % QA;[/icode] (which will get you a random number between 0 and 9)and … | |
Re: Did you try branching off from your 3 of a kind method? [code] bool FullHouse; if (Hand.Card[4].iValue == Hand.Card[3].iValue && Hand.Card[4].iValue == Hand.Card[2].iValue) { if(Hand.Card[1].iValue == Hand.Card[5].iValue) FullHouse = true; else ThreeOfAKindCard = Hand.Card[4]; } else if (...) etc. [/code] I know it doesn't combine your pairs check with the … | |
Re: It's got to be a static variable: [code] struct example{ static int id; float gpa; string name; }; int example::id=34440; [/code] Should be identical for the class (static variable/defined after the declaration). | |
Re: Seems to depend on which IDE you use. Visual Studio has some 3rd party tools available (see [URL="http://stackoverflow.com/questions/30947/visual-studio-08-spell-check-addin"]this [/URL]article). If you just have a text editor you can probably write a program to pare down your code to the strings (marked by a line number), import that into word, correct … | |
Re: The best way is to pass your struct around (you did it by reference into getInfo() which is fine) So change the prototype of getAvg to take a school & also [icode] int getAvg(school &, int total); [/icode] instead of a student (which isn't known about until you made a … | |
Re: Since there is no inheritance type specified, the default is private. Therefore your public and protected members become private and your private members are not accessible to your derived class. Your protected variable from A is then becoming private in B, which is then not accessible from C. I think … | |
| |
Re: You've omitted and mismatched. You don't even call your function. At least try to get it to compile before you post--and if after that you have a "unbeatable" error, at least let us know what it is. | |
Re: Well, what do you consider to be the essential features of OOP? One hint: what kind of inheritance does C++ support vs. Java. I didn't do a net search but I'm willing to bet if you google this you'll come up with tons of "ammunition." Keep in mind that each … | |
Re: Evidently you can get the number of clicks through a mousemove event (accessing them as e.Delta). see [url]http://www.pcreview.co.uk/forums/thread-1313418.php[/url] | |
Re: Starting on line 84 there are some errors that,while they compile, they are not doing what you expect. 84: Where is i coming from? I see where it's declared but there's no value assigned to it anywhere and it doesn't change in the while loop 93,97: Should be == instead … | |
Re: NumericUpDown is a Winforms control in .NET. @OP- I tried a couple of times to get WaltP's idea (and using [URL="http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/def03dac-1602-4c46-8c76-d508150f6b46"]this[/URL] article for VB) to work but for some reason when I would try to wrap around I would get a StackOverflowException. The solution is using a DomainUpDown control (in … | |
Re: Post how you changed the code... I changed the prototype and the definition and it lets me enter the coordinates (then it does nothing so I'm not sure what to expect), but I don't get a stack overflow. Just a curiosity question: how come you didn't have solveMaze return a … | |
Re: Functions can go before main() as you have it, or they can go after main() but in that case you'll need a prototype before main to tell the compiler what to expect later on. In your example, for your method SearchN [icode] int SearchN(vector <string> &lastname, string searchName);[/icode] or simply … | |
Re: Hate to be a "Me too" but me too just now. I had also experienced the 15 second message Salem got a few days ago. I'm going to lie awake tonight staring at the ceiling wondering why me. :D | |
Re: [quote] I would drop MFC like a hot rock and learn up on WPF [/quote] A caveat to that is in order to access the managed libraries one must code in [URL="http://www.codeproject.com/KB/mcpp/cppcliintro01.aspx"]C++/CLI[/URL] which is in some cases more similar in syntax to C# and yet has its own syntactic quirks … | |
Re: Firstly, please use code tags (there's still time to edit your post and put them in). For your for loops, you are incrementing your values in your initialization step (and thereby skipping over the first value) and you were losing your last (if you want it) by having a termination … | |
Re: Take a look at the example on [URL="http://www.cplusplus.com/reference/clibrary/cstring/strcat/"]this[/URL] page. Is that what you are trying to do, except with digits? | |
Re: You need to type ./a.out (or if your program is named with the -o switch) ./nameofyourprogram See [URL="http://www.unix.com/high-level-programming/7073-running-c-c-program-unix.html"]here[/URL] for an explanation that has a way around it (I'm familiar with the problem but I'm not so much a Linux guy so I don't know the dotfiles as well to advise … | |
Re: I believe it's a known problem. I don't have a solution offhand but unless you are needing 6.0 for MFC or ATL work then you should probably grab the 2008 express edition ([url]http://www.microsoft.com/express/Downloads/#2008-Visual-CPP[/url]) it does console programs, Win32, and Winforms via C++/CLI. | |
Re: Did you try googling "flow charts" or "flow charting"? There are a bunch of links and most of them have the symbols. Happy hunting. | |
Re: Is there anything in FromInventory once you get inside of your method? I would verify it contains what you think it does and is as long as you expect. Second thing with the name is straightforward. Change your cin to a [icode] cin.getline(InputName,10);[/icode] that way it will get the spaces … | |
Re: This seems to be a popular implementation: [url]http://weblogs.asp.net/fbouma/archive/2009/05/18/multi-value-dictionary-c-source-code-net-3-5.aspx[/url] | |
Re: I just responded on your other thread. lol When you have a chance you should flag down a mod (you can hit your own flag bad post) and have them close one (or merge them, but I think closing's easier) so it doesn't get confusing. | |
Re: What are some of the reasons you would propose? (since clearly you're not asking this for homework or anything ;) ) Also note this is one of those questions where your professor may think there is a right answer but unless you're talking about % total of software projects in … | |
Re: Start a new project in VC++ this time [I]uncheck[/I] precompiled headers and leave empty project unchecked. Add your files to the project by right clicking on the solution/Add.. etc. and you can clear out all the other files (or just exclude them from the project to be safe). You've probably … | |
Re: For next time, please use the code tags [noparse] [code] //code goes here [/code] [/noparse] Count needs to be initialized to zero before the loop, otherwise you're getting whatever junk is in there upon declaration. If you want a space in your output just do [icode]outfile<<firstName<<" ";[/icode] or wherever you … | |
Re: It's looking for a main() with the 2019 error. It needs some type of entry point to make the exe unless you are making a library (which I didn't read your other thread but it doesn't sound like that's what you're doing). | |
Re: [code] while(x!=-999); //this semicolon ends your while right there x++; //without the semicolon only this would be part of the //while loop cout <<" enter a number (-999 to quit)"; cin >> x; [/code] Solution: [code] while(x!=-999) { x++; cout <<" enter a number (-999 to quit)"; cin >> x; … | |
Re: For next time, don't necessarily start up a new thread when people might still be working on that exact same issue in your old one, it gets too confusing. | |
Re: Your get_lname method is void and on 141 you are trying to compare two return values from it using strcmp. Try something like this: [code] Name_t lname; Name_t nextlname; CSCI208Class[I].get_lname(lname); CSCI208Class[I+1].get_lname(nextlname); if(strcmp(lname,nextlname)>0) [/code] or something to that effect. Or you could change the return type on get_lname() to Name_t but … | |
Re: For your overloaded << operator it would have to be defined as [icode] ostream& operator<<(ostream& out, [COLOR="Green"]const [/COLOR] SparseMatrix& rhs);[/icode] otherwise the compiler is unsure whether the method will try to modify the const object or not. | |
Re: Check out the [URL="http://gmplib.org/"]GMP[/URL] for the level of precision that you need. | |
Re: Just my 0.02 but it sounds like it might be a candidate for a singly linked list. You can enter the datum into it's proper place in the chain as it's coming in from the file. That approach is basically sorting the data but it doesn't explicitly take everything into … |
The End.