1,118 Posted Topics
Re: You haven't told the compiler what a [b]vector[/b] is, so it considers it an unknown type and goofs-up. Either add a [inlinecode]using std::vector;[/inlinecode] somewhere at the top, or say [inlinecode]std::vector <Car*> foo();[/inlinecode] Hope this helps. (Isn't it annoying when the silly stuff gets you?) [edit] BTW, the header file should … | |
Re: There is nothing wrong with it. You'll just get a reference to a temporary default. The best advice is to write [inlinecode]const std::string& error = std::string()[/inlinecode] as your argument. This will take strings and char*s equally. Hope this helps. | |
Re: That's called an [b][i]operator overload[/i][/b]. The << and >> operators are bit-shift operators, but in C++ the STL uses them with iostreams as insertion and extraction operators. In other words: [inlinecode]cout << "Hello world!" << endl;[/inlinecode] cout is the left object << is the operator "Hello world!" is the right … | |
Re: The FIFO will never have input until you write something to it. Since you don't write anything to it, [b]select[/b]() will always say that there is no input waiting. Remember, a FIFO [i]must[/i] be open at both ends (which you have done), and to read data you must [i]first[/i] write … | |
Re: The only two things I see that are guaranteed problems are first in [b]EnterName[/b](). You should input text using [b]getline[/b](). [code=C++] void WordRead::EnterName() { cout << "Type in the text file path you wish to read: "; cin.getline( theFile, 1000 ); } [/code] And second in [b]LoadFile[/b](), your loop will … | |
Re: "Overloading" (at least in C++) means that you have more than one function with the same name. In this case, you have three different constructors, but they all have the same name. The difference is the number and type of arguments it accepts. The first takes no arguments, so it … | |
Re: You have discounted newline conversions. On Windows, the newline character represents the ASCII sequence CR LF. When your program reads it, it gets '\n'. The newline is encrypted thus and so the output file is shorter than the input file, because the encrypted data doesn't have as many '\n's (if … | |
Re: There is nothing inherently evil about [b]system[/b](), or executing other executables; just be aware that you must be careful how you do it. | |
Re: You need to rethink why you are using a loop. Ideally, if you have to do things multiple times, it suggests a loop and/or an array. Since you need to remember five numbers, instead of writing: [inlinecode]int num, num1, num2, ...[/inlinecode] you can instead just use an array: [inlinecode]int items[ … | |
Re: They will remain separate programs, but I think you are asking if your C++ program can automatically run the VBA program so that the user doesn't have to? You have a variety of options. You can use [b]system[/b]() (#include <cstdlib>). [inlinecode]system( "\"C:\\Program Files\\MyVBAProgram\\VBAProg.exe\"" );[/inlinecode] On Windows you can use [URL="http://msdn.microsoft.com/en-us/library/bb762154(VS.85).aspx"][b]ShellExecuteEx[/b]()[/URL] … | |
Re: Ah, I see the problem. On line 52 you are assuming something about the input with [inlinecode](next >= 0)[/inlinecode]. (According to the instructions it should be [inlinecode](next > 0)[/inlinecode].) If you wish to use a semaphore item to terminate input, it must be passed as argument to the function. However, … | |
Re: For the array problem: Without using an intermediary array of some kind (via recursion or on a stack or whatever) the only other way I can think to do it is with math. You'll need a bignum library, and a list of the first N prime numbers (where N is … | |
Re: Like [b]iamthwee[/b] indicated, there is no standard way to do that. You'll have to do something OS-specific. I suggest you check out the Curses library. POSIX: [URL="http://www.gnu.org/software/ncurses/"]NCurses[/URL] Win32: [URL="http://pdcurses.sourceforge.net/"]PDCurses[/URL] Hope this helps. ![]() | |
Re: [URL="http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c8647/"]Win32[/URL] [URL="http://linux.die.net/man/2/reboot"]Linux[/URL] [URL="http://developer.apple.com/qa/qa2001/qa1134.html"]Mac OS X[/URL] Hope this helps. | |
Re: [URL="http://en.wikipedia.org/wiki/Call_stack"]Some theory[/URL]. [URL="http://www.unixwiz.net/techtips/win32-callconv-asm.html"]More theory with concrete examples[/URL]. [URL="http://www.geocities.com/siliconvalley/park/3230/x86asm/asml1010.html"]Some actual assembly examples[/URL]. [URL="http://www.masm32.com/board/index.php"]A wonderful place for MASM/32 users[/URL]. Have fun! | |
Re: Please don't shout. Adding a background depends on the toolkit you are using. If you are using straight Win32 API, you'll need to process the WM_PAINT message sent to the form and draw the bitmap before you let any other controls draw. If you are using a toolkit, please tell … | |
Re: I think you need to spend some time tracing through your algorithm. I'm not sure exactly what it is supposed to do, but I don't think it is doing what you want it to do... (Given "HELLO", the list it builds is H, E, L, LL, ...) In any case, … | |
Re: Using the old BGI functions you are pretty much out of luck... Sorry. Are you using an old Turbo C compiler or are you using the WinBGIm package? | |
Re: [code=C++] #include <algorithm> #include <functional> ... transform( a.begin(), a.end(), b.begin(), result.begin(), minus <pair <foo, bar> > () ); [/code] You'll have to define what the difference between two pairs<> is... (by overloading the - operator) Hope this helps. | |
Re: The InputBox() function is a nice wrapper for some simpler API calls. [URL="http://www.codeproject.com/KB/dialog/w32inputbox_1.aspx"]Try here[/URL]. Hope this helps. | |
Re: In C and C++, nothing is automatically initialized. (I'm pretty sure.) You can use the STL [B]fill_n[/B]() function to initialize it for you: [code=C++] #include <algorithm> // fill_n() and copy() #include <iostream> // cout, of course #include <iterator> // ostream_iterator<> #include <limits> // numeric_limits<> using namespace std; int main() { … | |
Re: Probably not. LC3 only exists in textbooks and moreover, people who volunteer here don't want to do your homework for you. Give it an honest effort and we will help as you go along. | |
![]() | Re: All objects in Delphi, including 'string', are allocated on the heap. When you resize a dynamic array the unused objects are automatically destructed for built-in types only -- so in this case, yes. When you set the length of a dynamic array to zero the dynamic array object itself is … |
Re: The compiler believes that [b]seating[/b] is an integer. The OP placed the cast there to try to get rid of the error message. Can we see the class definition where [b]seating[/b] is declared? Is there anything else between the class and the variable? Did you #include the header in the … | |
Re: I don't know how you got that far... You never initialize [B]coeffs[/B]. You must set its length before playing with any elements. Or push elts onto the end. Hope this helps. | |
Re: [URL="http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.15"]C++FAQ-Lite 13.15[/URL] Hope this helps. | |
Re: You'll have to google for each of these. The grid classes have methods to insert and delete rows. To display things other than text you'll need to set the [B]DefaultDrawing[/B] property to [B]false[/B] and override the [B]OnDrawCell[/B] event. Good luck! | |
Re: In the combo box 'select item' event handler, use [URL="http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx"]ShellExecute[/URL]() to start VLC with the name of the file to play as argument. You can use the returned process handle with [URL="http://msdn.microsoft.com/en-us/library/ms687032.aspx"]WaitForSingleObject[/URL]() (or any of the [B]wait[/B] functions) to wait for VLC to finish. Hope this helps. | |
Re: Dog and Cat don't relate to each other, and should probably not be friends. (No joke intended, though it is funny anyway...) "Friends" in the C++ sense mean that some [i]foreign[/i] object has access to your object's internals. This is useful, and quite often, but should not be used indiscriminately. … | |
Re: [quote]Use only spaces, and indent 2 spaces at a time.[/quote] Yes! Vindication! Bwaa hah hah hah ha haah PS I don't like tabs. | |
Re: Do you mean that when you use the IDE to assign the icon to your application that the resulting EXE's icon is missing its transparency? It could be that the IDE is too old to handle alpha transparency (bit-transparency should work just fine). In which case you will have to … | |
Re: ...but that is not guaranteed. It is [i]usually[/i] a safe bet that it contains at least the simple name of the executable ("foo.exe"). It may also contain either an absolute path or a relative path. On POSIX systems (Unix, Linux, Mac OS X, etc), use [URL="http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html"]getcwd[/URL]() and combine the result … | |
Re: Unfortunately what you are trying to do can't be done directly. The only time the sizeof/sizeof idiom works is on the original array[] variable. Pointers and function arguments etc don't know anything about the original array... The two usual solutions are: [list=1] [*]Pass the size of the array as an … | |
![]() | Re: Nope. (Sorry.) [edit] I could be wrong. Someone might have made a hack to do this... It might be worth you while to ask over at the [URL="http://www.tek-tips.com/threadminder.cfm?pid=102"]Tek-Tips Delphi[/URL] forum. |
Re: What do you mean by 'it returns the wrong answers'? How are you returning data from the console application? | |
Re: To get a filename without path or extension you need to do some string manipulations. Here are three procs I use all the time (well, in C++... I haven't used C in a while): [code=C] #include <stdlib.h> #include <string.h> /* ExtractFilePath() * Returns a new string containing the directory information … | |
Re: Here's a wild stab in the dark: you are using a really old compiler like Turbo C. If I'm right, then you should visit one of the following and get yourself a compiler that makes 32-bit executables: [url]http://www.mingw.org/[/url] [url]http://www.turboexplorer.com/[/url] [url]http://www.microsoft.com/express/vc/[/url] Hope this helps. | |
Re: You aren't erasing the [i]iterator[/i], you are erasing the [I]contents[/I] of your map. An iterator is practically always a locally-constructed variable, so you don't have to worry about destructing it. From your point of view (the programmer) you can consider an iterator the same as a pointer into a container … | |
Re: The "hex" file is really just a plain-vanilla text file. Each byte is represented by a two-digit hexadecimal value: 00..FF. The first number is the relative address of the first byte listed on that line. In the example you listed, the first byte listed on the first line is at … | |
Re: You've got the general idea. The [inlinecode]%[/inlinecode] sign is the [b]modulo[/b] (or [b]remainder[/b]) operator. So what it is saying is: "If the number I am looking at ([B]trial[/B]) divides evenly by the indexed prime (which should have been written as [inlinecode]primes[ [B][/B]i[B][/B] ][/inlinecode] to be less confusing), then we have … | |
Re: I know next to nothing about databases (because I [i]really don't like[/i] messing with them). But I wonder, being separate forms, are you using a separate connection to the database in each form? It sounds to me like the second form is trying to modify something that is locked by … | |
Re: Every version of python I've ever gotten (including the last three) came with DLL files. [code] C:\WINDOWS\system32>dir python*.dll Volume in drive C is Ceres Volume Serial Number is 0000-0000 Directory of C:\WINDOWS\system32 02/08/2005 05:23 PM 979,005 python23.dll 10/18/2006 09:35 AM 1,871,872 python24.dll 02/21/2008 01:11 PM 2,117,632 python25.dll 3 File(s) 4,968,509 … | |
Re: No. With some old BASICs you can play with the [B]SCREEN[/B] command to set the window mode, but GWBASIC doesn't understand anything but CGA modes... Also, the forum you want is [b]Legacy and Other Languages[/b]. Hope this helps. | |
Re: I think by this point [b]AD[/b] is tired of answering the same question the same way again and again and again... If you want the machine code for the function, tell your compiler to output the assembly code, chop off everything except the function, and run it through your assembler, … | |
Re: OK, since no one else is looking at this one... (I had to go learn to do the Matrix Chain Multiplication) I think you are missing something here. The MCM algorithm isn't actually supposed to [i]multiply[/i] the matrices together. It is just to tell you the best [i]order[/i] in which … | |
Re: The [B]string[/B] class does have methods specifically for doing that sort of stuff. But you can use the standard algorithms just as easily. [code=C++] #include <algorithm> // needed by using_iterators() #include <cctype> // needed by using_iterators() #include <functional> // needed by using_iterators() #include <iostream> #include <iterator> // needed by using_iterators() … | |
Re: There is no particularly 'easy' answer, but you can use the STL to do it: [code=C++] #include <algorithm> #include <iostream> #include <iterator> #include <sstream> #include <string> #include <deque> // Our dummy class template <int n> struct column_n_t: public std::string { }; // Our dummy class input extractor template <int n> … | |
Re: Please use [[B][/B]code[B][/B]] tags. You've declared the [b]monthEnd[/b]() function as existing, but you don't appear to have defined it anywhere. If you prototype a function somewhere, there should be a corresponding function elsewhere. When you compile, make sure to turn as many warning messages on as you can. The compiler … | |
Re: The best way to do that is to use a visual trick. Capture an image of the button. (You can do this by using [b]GetWindowDC[/b]() on your form, then using [b]BitBlt[/b]() to transfer the image of the button into a [b]TImage[/b] canvas.) Actually hide the button. In your form paint, … | |
Re: You can't use Int 21h or any other DOS interrupt service unless DOS (or WinXP or earlier) is running --hence the reason it works in the emulator and not in real-life. The purpose of the OS is to manage software and provide access to hardware devices (such as disk drives). … |
The End.