2,045 Posted Topics
Re: [B]You should create a second [I]class [/I]called finalLab.[/B] You have made finalLab a method of the demoClass. [B]finalLab will have one method, one constructor and one property. The property will be a string called message.[/B] This will involve having a {get; set} after the property is defined [B]Your main method … | |
Re: WaltP was just pointing out that you need to take into account that row 0, row 19, column 0 and column 19 don't have neighbors to their up, down, left, and right respectively. Also, your for loops take into account 1-19, but your array actually starts at zero, so you … | |
Re: i goes out of scope (disappears) after your for loop has finished. Divide by count instead | |
Re: It's interpreting args[1] literally in the string, there's no translation that will take place. Make a C++ string out of "fc "+(string)args[1]+" ..\\o.txt" then pass that in as mystring.c_str() to system(). | |
Re: Once you have a breakpoint set, you can step through a few lines as needed and then hit F5 (or Continue in the debug menu or the green "play" button on the toolbar) and it will cycle through until it hits the breakpoint again. | |
Re: You have the word comment in your code outside of any of the comments /* printf("%s\n",buf);*/ comment | |
Re: use [icode] fin >> [/icode] and since you know the order of the line (1 string, 6 numbers, 1 string, 6 numbers, etc.) make a nested for loop (rows and then columns) to put them in their proper variables. P.S. It doesn't matter too much, but if you are going … | |
Re: That's also not the correct formula for the median I don't believe. AFAIK, if you have a set of numbers like 1 3 5 9 12, then 5 would be the median as it's the central value by count, 3rd from the beginning and 3rd from the last. When you … | |
Re: Welcome to the site. There are a number of inconsistencies that your compiler is trying to tell you about, this does not mean that your compiler is bad or faulty. [code] #include <iostream> //iostream.h is an outdated header from //prestandard days -- if your learning material //uses it it's probably … | |
Re: Next time please use code tags. I don't think you have to worry about the minutes at all when you are doing your conversion. Since you know you are entering in military time, you can make your if statement if `(pHour >=0 && pHour<12)` for the AM/PM portion (I see … | |
Re: It's the one that comes up first (probably by careful design) when you search "C++ [anything]" on Google but I like [url]http://www.cplusplus.com/reference/[/url] It has the functions/methods from the major libraries (C and C++) and little code samples for most of them. | |
Re: I think the problem is you need to convert your checkWinner function to return a bool (true if there's a win or a tie and false if not). As I was attempting to do that I was thinking that you really should try to pare down player1() and player2() into … | |
Re: * (unary, dereferencing) has higher precedence than addition or subtraction, so it's like (*a)+1-(*a)+3. | |
Re: He said he [I]has[/I] examples for Windows but what he wants is examples that work under Linux | |
Re: Line 12: Char should be char Line 38: ) in the wrong place Line 40: ) in the wrong place Line 41: Extra ) Line 47: Extra ) Line 58: ) in the wrong place There may be others. When you compile please try to look over the lines which … | |
Re: You need to put the strings in " ", so "BLANK","BLANK", etc. EDIT: It was in your prior posts, I overlooked it, sorry! | |
Is that "this thread is over three months old" warning new(it's possible I totally missed it before)? Either way I like it!! | |
Re: Welcome to the site. For us to best help you with your assignment, please post all relevant code and any specific questions that you have. | |
Re: Is there more to main? Sounds like you want to put a while loop so you can cycle through it again once you are done with the transaction. Also, in your last post you asked about the boolean for active/inactive. I was saying you should put a member in your … | |
Re: Can you call [icode] Person::operator==(s) [/icode] in the derived class and AND the results with your derived class comparison? so like: [code] bool operator==(const Student& s) const { return (myStudentId == s.myStudentId && Person::operator==(s)); } [/code] EDIT: I did test it out and it seems to work. | |
Re: I ran across this (pursuing it out of curiosity) [url]http://services.aonaware.com/DictService/[/url] I have never used it and I'm not sure what the licensing terms are. | |
Re: I think the pointer is not initialized so when you try to dereference it the first time *s = a; it crashes. Setting s = &a; in conjunction with s = &b; after incrementing the pointer also works. Your cout should be dereferenced to view the char. | |
Re: If you are calling your function with a specific element of each of those arrays, you are no longer passing an `int a[]` you are passing in a plain int. Your definition is treating it like you are sending in the whole array of size 20. If you are letting … | |
Re: Shouldn't OP's overloaded operators for + only take one parameter (and return real &)? (or am I missing something) | |
Re: Unless you specifically send a linebreak to cout, it will keep printing on the same line, so basically you need: [code] cout <<" 1-10"; for loop(over the number of stars for that range) cout <<"*"; cout <<endl; //go to the next line [/code] | |
Re: pop in a variable to get that value for use in the subsequent function call [code] double avgstore; ..... Q6[i] << setw(8) << Final[i] << (avgstore = CalculateAvg (students, id, fname, lname, Q1, Q2, Q3, MidTerm, Q4, Q5, Q6, Final, i)); cout <<calcGrade(avgstore); (try it tacked onto the end of … | |
Re: [QUOTE=merse;1066991]Sorry about that, but it was just a missprint, the problem is the same with this [CODE]struct mystruct { double x; mystruct(double x1) : x(x1) {}; }; T x; [b] Here you are trying to use a default constructor for your struct and there isn't one [/b] [/CODE][/QUOTE] I couldn't … | |
Re: Can you add a private bool member to your savings class and simply use your status method to set it or unset it? You could have a "getter" to check it when the need arose. So in your withdrawal case, it would be savings.status(false); Also, put code tags around everything … | |
Re: I think what you mean is [icode] button2.PerformClick() [/icode] | |
Re: Before anything else: I told you this was wrong... [icode] if (Q1[i] <= Q2[i] && Q3[i] && Q4[i] && Q5[i] && Q6[i]) [/icode] should be Q1[i] <=Q2[i] && Q1[i]<=Q3 && Q1[i] <=Q4[i] && Q1[i] <=Q5[i] && Q1[i]<=Q6[i] I know what you have compiles but that doesn't mean it works the … | |
Re: I think a circle is tough (I'm not totally familiar with the graphics lib you are using) but probably doable with putting one (dot, star etc) on the top line, on the next putting two spaced 1 away from the center dot on either side and one down,then putting 2 … | |
Re: string getName(); in the declaration should be void getName(string []); (you're going to pass it in by pointer so you won't have to return anything) in main() declare a string mystr[5]; (or however big you want it) and call a.getName(mystr); Then you can access mystr directly in once you're back … | |
Re: Try [icode] yourtextbox.Text +="Your new line of text here \r\n"; [/icode] That gives you a carriage return and newline, and do this for every line that you add. | |
Re: The code from post #4 ran on my machine and produced an output file. | |
Re: From line 33: outFile<<command<<" : is inserted"<< list.InsertItem(item)<<endl; is the first example the compiler picks up (and then gives a billion errors from the streams) but any time you have a method directed into an output stream int must have a return value and your InsertItem is void. I think … | |
Re: Within your block [code] for (i = 0; i < 6; ++i ) { if ( students >> studentid[i] >> fname[i] >> lname[i] >> Q1[i] >> Q2[i] >> Q3[i] >> MidTerm[i] >> Q4[i] >> Q5[i] >> Q6[i] >> Final[i]) [/code] you have cout << all your stuff CalculateAverage() //prints out … | |
Re: Since your classes are really pointers you need the -> operator to dereference and dot them (*A.member() is the same as A->member() ) (also, instead of iostream.h #include<iostream> and instead of stdlib.h #include<cstdlib> and <ctime> in place of time.h -- these are the standard headers you should be using -- … | |
Re: Maybe I'm missing something but hashArray has nothing in it. I'm not sure why you are treating your numbers as chars? | |
Re: [QUOTE=GrubSchumi;1064300]Hi tasky23, You need a bit more to open the file. Declaring an instance of ifstream is the correct start but it should read: [CODE] ifstream infile2; //then to open the file. infile2.open("file.txt",ios::in); [/CODE] [/QUOTE] See: [url]http://www.cplusplus.com/reference/iostream/ifstream/ifstream/[/url] his notation is a shortcut. @OP: I think the brevity of your post … | |
Re: Please use code-tags the next time... double rad; double circum; double ar; double radius1; double circumfrence1; const double pi=3.141616; cout << "This Program Finds The Area, Radius and Circumfrence of a circle!" << endl; cout << "Please where the center of the circle is, please enter two numbers " << … | |
Re: Just take away the <=10 and substitute in <10, going less than or equal to will overstep your array. Also, you can accomplish the first part with just the loop variables (no need for n) ;) | |
Re: Shouldn't line 32 just be [icode] p = i+p;[/icode] (or p+=i; )? That way you put your interest into principal and iterate again. | |
Re: You have to [icode] #include <algorithm> [/icode] and call: [icode]sort (myvector.begin(), myvector.end());[/icode] (see [url]http://www.cplusplus.com/reference/algorithm/sort/[/url] for a reference) | |
Re: .NET has this [url]http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx[/url] but I don't know if you wanted win32/unmanaged (you'd need the HighResolution on -- I'm trying to find the order or magnitude of the smallest timestep -- looks like it's 100 nano) [code] Elapsed = 00:00:00.0052618 [/code] Though I'm sure the figure it gives comes with … | |
Re: The {0,20} is a placeholder and format specifier for a variable that was in the other example you had. For example: [code] int i = 1; char a = 'a'; double pi = 3.14159; Console.WriteLine("{0} {1} {2}",i,a,pi); [/code] prints out: 1 a 3.14145 (each placeholder is replaced by the value) … | |
Re: Me again... :) ROW is not in scope in your function (I checked your other post). You'll want to either put it through a debugger (or put in a temporary int variable to count your loops or print out something etc) to make sure it goes through enough loops. It … | |
Re: Your counter values do not exist outside of the loop scope e.g. [code] void getData( int compMenuList[], int counter1) { counter1 = 0; cout << "Enter the menu choice(s): "; for(counter1 = 0; counter1 < 7; counter1++) { cin >> compMenuList[counter1]; if(compMenuList[counter1] = -999) break; } } [/code] Firstly, counter1 … | |
Re: Parent class functions that need to be different than their parent class counterparts must be labeled virtual. This lets the compiler know that the method will be attached dynamically (i.e., depending on the type of the object at runtime). If I have a class called hasmotoroutside I can derive and … | |
Re: I'm sure there are more elegant solutions to this problem, but here's an example I thought of [code] bool exitloop = false; switch(ch1) { case 1 :{ while(1) { cout<<" Directory Selection"<<endl; cout<<" 1. Computing Science "<<endl; cout<<" Enter your choice : "; cin>>ch2; switch(ch2){ case 1 : break; //out … | |
Re: Ancient Dragon gave you some links to freely available libraries in your other post. If you're up for some theory check out [url]http://en.wikipedia.org/wiki/Lempel-Ziv[/url] but it's definitely preferable to use a library rather than re-implementing from scratch. Please elaborate on what help you need with the compression if this is not … |
The End.