2,045 Posted Topics
Re: Use the "as" keyword to cast them (I ignored the list portion for simplicity): [code] BaseGameEntity bge = new Drop(); (bge as Drop).DropMethod(); [/code] or you can use the old fashioned [code] ((Drop) bge).DropMethod(); [/code] | |
Re: Assign it to a std::string or char array. Within your class you can design your own methods for doing operations with the numbers. | |
Re: The math.h functions take an angle in radians. Use the conversion pi radians is to 180 degrees to convert your angles before sending them in. | |
Re: Next time please use the code tags. Type: [noparse][code] //code goes here [/code][/noparse] Since you assign bonusContributed a value in an if/else structure, if your sales are less than 10,000 you won't assign it a value at all. Even if it is >=10000, your if/else if statements in the second … | |
Re: First, another issue at hand. [code] #include <iostream.h> #include <fstream.h> #include <stdlib.h> [/code] should be [code] #include <iostream> #include <fstream> #include <cstdlib> [/code] The ones with the .h are prestandard C++ headers (and when using stdlib.h from c, use the cstdlib version). There's a design problem brewing here. If you … | |
Re: [icode]if(values == 00) [/icode] This will not work as written. Values is an integer variable and I believe this will simply register as 0. You'll have to use another sentinel value or take in input as a string and convert it to int. Also, your function returns void so attempting … | |
Re: [quote]i want textbox to show all the values i.e. as the values are generated by generate_data class, the values should be passed to textbox in new line instead of overriding. [/quote] Or change line 26 to [icode] textBox1.Text +=value; [/icode] | |
Re: Also, not to be fussy (but I will be anyway) isn't this C++ code? | |
Re: Make sure it's between 0 and 9 and then add '0' to it. [icode] char a; a= '0' + 1 [/icode] (a = '1') | |
Re: You're doing a couple of things that are confusing to me. When you're getting a random word, you're reading your file back in again. You already have the words in the array, you should pick a random one out of there. You also don't use the return from randomword at … | |
![]() | Re: What do you mean by fails to execute? What do you end up with in the string? Does it throw an exception? EDIT: I just tested it with 3 copies of a (short) novel in a row (~500K) and had no problem |
Re: All you probably need is [icode]DateTime::Now.ToString() [/icode] to get the current time and date. I'm not sure why you would need the picker but if you want the user to specify the date you could get it by [icode] dateTimePicker1->Value.ToString() [/icode] EDIT: Was typing during FBody's post but what he … | |
Re: What have you tried? Hint: read a line into a string, output the string (not the only way of course). | |
Re: IMO, Head First C# is a good way to get from the ground to the first/second floor quickly. From there you could select something more suited to a specific area where you want to end up. | |
Re: If you are initializing min to zero then it's always going to be lower than any (positive) number that you encounter in the list. Set minimum initially to the first element of the list (works when you're finding max too). EDIT: Beaten by vmanes. Curses, foiled again! | |
Re: Thankfully this issue hasn't lead to bonuses (or lack thereof) in my region. The scores of the standardized tests (similar to what Vernon was talking about) do count for the schools stature in the state and district so it can affect things like funding. The problem is that the "benchmarkers" … ![]() | |
Re: You have to include <windows.h> and change a couple of compiler settings to get it to work with the unmanaged code. See [url]http://social.msdn.microsoft.com/Forums/en-GB/vcgeneral/thread/4d24375c-15c5-4c31-ac39-304750a1e556[/url] | |
Re: You're probably a lot more likely to get the help you need someplace like [url]http://forums.ni.com/ni/[/url] (not to say you can't post it here, but just a friendly suggestion) | |
Re: [QUOTE=chary8088;1187748]C# language ,,this is CPP forum[/QUOTE] Meet [URL="http://en.wikipedia.org/wiki/C%2B%2B/CLI"]C++/CLI[/URL]. We keep it out in the woodshed but it's a member of the family nonetheless. :) | |
Re: Add a constructor to your class: [code] class DataBase { OleDbConnection MyCon1; OleDbCommand MyCmd1; OleDbDataAdapter MyDataAdapter1; DataTable MyDataTable; System.Windows.Forms.TextBox textBox; public DataBase(System.Windows.Forms.TextBox textBox) { this.textBox = textBox; } //rest of your class } [/code] (obviously a using directive will eliminate the System.Windows.Forms, but it is not on there by default … | |
Re: Post the code, it sounds like you plunked in an unnecessary prototype again. | |
![]() | Re: Do you mean something like: [code] char a, b; //read in a and b and change to caps int[,] occurrences = new int[26, 26]; Console.WriteLine("The Co-occurrence of " + a + " and " + b + " is " + occurrences[a - 'A', b - 'A']); [/code] |
Re: Yes, there is an overload which takes a char. A good reference:[url]http://www.cplusplus.com/reference/string/string/find/[/url] EDIT: AD's got it ^^^^^^^^^ (but that site is still a good reference) | |
Re: [code] MPI_Send ((void *)&line, 1, MPI_CHAR, 1, 0xACE5, MPI_COMM_WORLD); [/code] I think (can't test it unfortunately) should be: [code] MPI_Send (line, strlen(line)+1, MPI_CHAR, 1, 0xACE5, MPI_COMM_WORLD); [/code] since line is a char array it is already a pointer. | |
Re: Check the starting index on line 17, what's the last index of an array of length numchars? You're on the right track with the loop but run through it by hand, you're always replacing the last entry of backwards with the next. See what you can come up with. | |
Re: [QUOTE=firstPerson;1186154]put the "cout << endl; " at the end of the first for loop. So do this : [code] for(i=1;i<5;i++) { for( j=1;j<6; j++) { infile>>random[i][j]; cout<<random[i][j]<<endl; } cout<<endl; } [/code][/QUOTE] Maybe you caught it already but line 6 of the snippet should probably be [icode] cout<<random[i][j]<<" "; [/icode] (no … | |
Re: I didn't go over your code in great detail. I was able to run it with the following output: [code] There is no element at the given ID. The ID of the station being added already exists. Name: Boardwalk, ID number: 1 Name: Boardwalk, ID number: 6 Name: New York … | |
Re: If you have an 8 digit binary number, you want to have it so you're multiplying the value in position n with 2^(7-n). You could send in the size of the number in digits as a third parameter to your function that wouldn't change. | |
Re: Put in a [icode] cin.ignore()[/icode] after the [icode] ans = getche(); [/icode] line. The newline ('\n') from the when you entered y or n the first time was staying in the input stream and getting picked up by the getch() which took it as input and moved on. I don't … | |
Re: I wouldn't make lastLetter and nextToLast neither pointers nor arrays (there's not much point to having a 1 element array anyway). I would make them both chars and set lastLetter to verb[size-1] and the other to verb[size-2] (using the array notation for the string). Another problem you are going to … | |
Re: You still have the for loop within the while loop which I think someone had pointed out already. What happens when your file has 9 values in it? You don't need it anyway, just increment j within that while loop. | |
Re: Take it into a string and parse everything (either with your own function that multiplies out the place values or something like atoi) up to the slash as one integer and parse everything after as a second integer. Or a simple way to do it would be have the user … | |
Re: If you're skipping over the design phase completely you're doing yourself a disservice. All of the work with the use cases, CRC cards, etc. should be done before you write a single line of code, that way you can include the OO principles from the ground up. | |
Re: Disp and input should just take plain ol' strings. I'm not sure what you are trying to do with the [ ] but I don't believe it's correct. In the case on the last 2 lines you'll have to use something like sprintf to make a string out of the … | |
Re: [QUOTE=Anarionist;1174377]I'm trying my best to learn linked lists but am having a difficult time understanding them exactly any way debugger returns SIGSEGV [code] #include <iostream> using namespace std; typedef struct node *p; typedef struct data * d; struct node{ p next; d dat; }; struct data{ int id; }; int … | |
Re: SelectionStart is a property specific to TextBox. Text is a property that all Controls have. To access that property you need to downcast the controls to their particular type using a dynamic_cast to TextBox^ type. You'll have to do some checking to make sure that you have the right controls … | |
Re: [QUOTE=bletchley;1182577]Got it to work by changing the include in main.cpp from "LList.h" to "LList.cpp" and only doing "g++ Main.cpp -o Main".[/QUOTE] In this situation you should have left it as [icode] #include "LList.h" [/icode] and compiled it as [icode] g++ LList.cpp Main.cpp -o Main [/icode] that way LList.cpp gets compiled … | |
Re: The way you have it will only store 255 characters, not 255 strings. Make your array 2D. For example, [icode] char arr[255][10]; [/icode] would allow you to store 255 strings of 9 characters each (plus a '\0'). You could enter strings into them by using [icode] fgets(arr[i],sizeof(arr[i]),stdin); [/icode] where I … | |
Re: Lines 17 and 18 of password.h do not need the Password:: qualifier. Since they are being declared within the class it is assumed just like it is for the constructor/destructor. | |
Re: I'm still confused. Is this for a WinForms application? I'm not sure what label you are talking about that has a caption (and I'm only guessing about what you mean by standard bar). This will work for a generic label: [code] double pi = 3.141592654; label1->Text = String::Format("{0:F4}",pi); [/code] | |
Re: Are you allowed to use std::vector or are you limited to arrays? A vector would let you expand your set as needed. See [url]http://www.cprogramming.com/tutorial/stl/vector.html[/url] for a quick introduction. | |
Re: [QUOTE=daviddoria;1179110]Is this c++? I don't think [icode]ref class CSquare: Rectangle[/icode] or [icode]property int lt [/icode] are valid c++ statements. Dave[/QUOTE] It's [URL="http://en.wikipedia.org/wiki/C%2B%2B/CLI"]C++/CLI[/URL]. If one needs .NET winforms in a C++ application it's basically the only avenue. | |
Re: There are many ways you can make your life easier on this one. I'll focus mostly on 62-77. You should make your array only 26 members long. That way there is not a lot of wasted array space to confuse the matter. There's an easy mapping between chars and an … | |
Re: Code tags: it's simple. Type: [noparse][code] //paste your code in here Type: [/code][/noparse] (or highlight your entire code and click on the [noparse][code][/noparse] button on the editor toolbar. Now, there's a simple error hampering your progress here: [code] void open_input(ifstream& input, char name[])[COLOR="Red"][B];[/B][/COLOR] [/code] (that would have been on line … | |
Re: Characters are essentially nothing more than 1-byte integers. So if your letter that you were counting were 'a' what operation could you do to yield the index 0? How about for 'b' to yield 1? You'll kick yourself once you get it. So the array will hold integers and be … | |
Re: [code] if (pch1 != NULL) { cout << "My name, you say\n" << "It is Jubajee\n" << "Cool eh?\n"; redo = 1; } [/code] Are you talking about the above printing out [code] My name, you say It is Jubajee Cool eh? [/code] all at once? I'm unclear on what … | |
Re: There were a lot more errors than 2. In your output function you are missing some pairs of parentheses. As Excizted mentioned please learn to use code tags. Type in [noparse][code] //code goes here [/code][/noparse] It makes it very difficult to see what's going on with your code when the … | |
Re: How are you using "string" in C? Are you compiling it as C++? | |
Re: Can you show an example data file? I think if you know all the dimensions ahead of time you could just use a for loop to read in the data and make things slightly easier on yourself. |
The End.