1,118 Posted Topics
Re: [url]http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.1[/url] (Read the whole page) | |
Re: STL to the rescue. [code=C++] #include <algorithm> #include <cctype> // since you are using char* ... bool str_eq_ci( const char* a, const char* b ) { for (; *a && *b; a++, b++) if (std::toupper( *a ) != std::toupper( *b )) return false; if (*a || *b) return false; return … | |
Re: Are you sure all your class declarations end with ';'? Does your [b]node[/b] class in any way depend on [b]T[/b]? Without more code I can't help further. Sorry. | |
Re: It is complaining because you are trying to return an array that will disappear the instant the function terminates. I'd swear I just read/responded to this very issue not too long ago, but I can't find it. Since you aren't using the result of ADD_STUD, just make it [b]void[/b] and … | |
Re: You are trying to use a non-const iterator on a const reference. Use [inlinecode]std::vector<std::string>::const_iterator it = tabNames.begin();[/inlinecode] You might want to check out the tool referenced here to better understand those obnoxious STL error messages: [url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.17[/url] Hope this helps. | |
Re: Your syntax is correct, but you are probably not catching the correct thing. Usually the standard error is a descendant of runtime_error in <stdexcept>. Take a read through [url]http://www.parashift.com/c++-faq-lite/exceptions.html[/url] and check 17.6 and 17.7. Hope this helps. | |
Re: The error is because somewhere in there you are trying to dereference a pointer whose value is NULL. Without examples of OneClass and AnotherClass and exactly what method(s) you are calling to cause the error I cannot help further. | |
Re: When you first start your program, and every time [i]you[/i] modify the file, remember its last modification date (you can get that with the [b]stat[/b]() functions). Then just periodically check to see if the date has changed. On Windows, you can use [b]FindFirstChangeNotification[/b]() to create a notification object on a … | |
Re: You've got the wrong forum. Click the link at the top for "Web Development" and choose an appropriate forum there. Good luck. | |
Re: I don't imagine that recursion and permutations are very safe together without tail recursion. Use a modulo counter. For example, in the Arabic number system we use we have ten digits for each power. 0 1 2 3 4 5 6 7 8 9 To count through them all, just … | |
Re: Just change [inlinecode]CC=gcc[/inlinecode] to [inlinecode]CC=g++[/inlinecode] Behold, the Make Anything Makefile: [code] #----------------------------------------------------------------------------- # Make Anything Makefile #----------------------------------------------------------------------------- # For use with GNU Make # # The only prerequisite to using this Makefile is that the program source # files all reside in their own directory, with only ONE of these … | |
Re: Actually, he's talking about preventing someone [i]else's[/i] program from accessing the file system. Check out your answer over at CodeGuru. | |
Re: How about: [code=C++] #include <algorithm> #include <iostream> using namespace std; int main() { int numbers[] = { 12, -7, 42, 9 }; cout << "largest = " << max_element( numbers, numbers +4 ) << endl; cout << "smallest = " << min_element( numbers, numbers +4 ) << endl; } [/code] | |
Re: Good grief! [b]n.aggel[/b], you had the right idea to begin with, only your syntax needs help. Don't change the definition of the function, but just pass the appropriate pointer. [code=C] void array_function(int rows, int cols, float after[rows][cols] , float before[rows][cols]) { ... } int main() { int n = 5; … | |
Re: This looks like homework. If it isn't, you can use the [URL="http://www.cppreference.com/cppalgorithm/sort.html"][b]std::sort()[/b][/URL] algorithm. Hope this helps. | |
Re: The C++ standard does [b]not[/b] specify layout, so the internal layout of a class or structure will vary by compiler. (Though, for most compilers the first thing is a pointer to the v-table, then the fields, so old C code that relies on struct and struct.first_member will probably compile just … | |
Re: R U Japanese? (osu?) You have misunderstood the purpose of #include files. Each separate module (.c file) should be compiled separately (into a object file: .o or .obj). Each module should have a header file (.h file) that prototypes what can be found in the object files. For example, suppose … | |
Re: Have you used glClear()? | |
Re: If you know something about the distribution of dates in the file you can get the fastest time, but in any case you'll have to do a random-access search. This should help, but may not if the date is in a worst-case position: [list=1] [*]read the first date in the … | |
Re: No. (If you want to get technical, it depends on the quality of the compiler. But the most difference it will cause is a couple cycles, which is infinitesimal.) | |
Re: Please use code tags. It is easier on my poor eyeballs. There are issues involved with reading and writing to the same file. To do what you want to do, it is best to make a temporary file, then replace the original. [code=C++] #include <iostream> #include <fstream> #include <cstdio> // … | |
Re: Your top array (the one containing arrays) should be defined something like (assuming you are storing [b]int[/b]s): [inlinecode][B][COLOR="Green"]int[/COLOR][/B][] lists[ [COLOR="Red"]10[/COLOR] ]; // Ten arrays of variable length.[/inlinecode] Now you must decide how to know how long each array is. You could store its length as the first integer in the … | |
Re: The problem is exactly what it is saying. For example, you have a procedure prototyped as: [inlinecode][B]void[/B] GetTemperatures ([B]int[/B] Temperatures[], [B]int[/B] NumTemperatures);[/inlinecode] ...which clearly states that it requires two arguments. but in [b]main[/b]() you don't specify any arguments: [inlinecode]GetTemperatures ();[/inlinecode] You must specify the arguments: [inlinecode]GetTemperatures( HourlyTemperaturs, NumTemperatures );[/inlinecode] I … | |
Re: Yes, it should be cast to a BytePtr. If you don't then anything you add to it is multiplied by the size of the object's elements. [code=Delphi] type pPoint = ^tPoint; tPoint: record x, y: integer end; function get_point( points: pPoint; index: integer ): tPoint; begin inc( points, index ); … | |
Re: It could be quite a number of things. I'll need to see a lot more of your code. You haven't been overloading the == operator in funny ways or anything? | |
Re: [URL="http://www.cplusplus.com/doc/tutorial/files.html"]Start here[/URL]. When you hit the wall post your code and we'll help further. | |
Re: Yoink. OK, one last one, just for the weird operator concerns: [code=Delphi] procedure XOREncrypt( buffer: PByteArray; length: longword; key: PByteArray ); var i, j: cardinal; begin for i := 0 to (length div 8) -1 do for j := 0 to 8 -1 do buffer[ (i *8) +j ] := … | |
Re: That C code is a mess. And it is dangerous because it uses bitfields (which C++ does [i]not[/i] guarantee to be packed in any specific order -- so results vary by compiler!). Alas, why don't programmers stp usng stpd shrt nonsns nms. Anyway: [code=Delphi] uses SysUtils, // for PByteArray Winsock; … | |
Re: You are looking to do something pretty tricky. I can help you on Windows, but on another OS you might be up the creek without a paddle... What OS are you using? And how is the number displayed (in a window or on the console or in a line edit … | |
Re: If you know your target value will fit in a smaller integer, you really don't need to worry about endianness. Do as [b]tesuji[/b] suggests and let the compiler do the appropriate movement: [code=C++] fputc( unsignedlongvar, file ); // bits 8..31 are lost! [/code] Don't use [b]fwrite[/b]() for size-specific I/O. The … | |
Re: Get rid of the [b]int[/b]. You have [i]two[/i] variables named 'j' there: your iterator, and an [B]int[/B] local to the [B]for[/B] loop. [code=C++] vector<Number*>::iterator j; for (j = v1.begin(); j<v1.end(); j++) cout<<v1.at(*j)->getValue(); [/code] Don't forget proper indentation! Hope this helps. | |
Re: It might be worth your interest to check out Boost [URL="http://www.boost.org/doc/libs/1_35_0/libs/regex/doc/html/index.html"]RegExp[/URL] (which is a lot easier to use than that scary-looking website might make you feel), or [URL="http://www.regular-expressions.info/gnu.html"]GNU RegExp[/URL]. Or, for a simple program you might want to check out [URL="http://wiki.tcl.tk/"]Tcl/Tk[/URL], which excels at handling strings and has a powerful … | |
Re: Can you tell us the type of pipe and the operational modes of each end? I suspect that you have got an unstable combination and/or buffer lag. | |
Re: I'm confused at what you want. "3A" > "20A" > "-3A" > "-20A" The algorithm is working properly. [edit] Oh, I get it. Remember, strings and numbers are not the same thing. You'll have to convert to numbers and sort on that. | |
Re: You're playing with deep stuff. Google "msdn task scheduler and take a look at the task scheduler scripting objects and interfaces (depending on how you want to do it). You'll need admin rights to do it. Hope this helps. | |
Re: Perhaps he would like to use some of the power of STL streams to parse the string. Use an [URL="http://www.cppreference.com/cppsstream/constructors.html"][B]istringstream[/B][/URL]. [code=C++] #include <iostream> #include <sstream> #include <string> int main() { using namespace std; string full_name; string first_name; cout << "Please enter your full name> "; getline( cin, full_name ); // … | |
Re: Typically all the forms you create in the IDE are automatically created when your application starts. (You can choose which forms are auto-created from the Project->Options menu.) You can see the code that does it by choosing Project->View Source (to see the WinMain() function). What appears to be happening is … | |
Re: Yep. You can set the form's [b]ClientOrigin[/b] property (which is a [b]tPoint[/b]) or You can set the [b]position[/b] property of the form's [B]HorzScrollBar[/B] and/or [B]VertScrollBar[/B]. Have fun! | |
Re: I see no error. What exactly does the error message say? | |
Re: In Delphi (as in C++, etc.), a [i]reference[/i] is really a veiled pointer. Hence, when you declare a variable of type [inlinecode]var TMyObject: MyObject;[/inlinecode] space is not reserved for the entire object; rather, [b]MyObject[/b] is a [i]pointer[/i] to a [b]TMyObject[/b]. The compiler is smart enough to know the difference, but … | |
Re: You can't overload the + operator to be [b]const[/b] unless you change the operation to not modify [b]*this[/b]. In other words, if you change [b]*this[/b], get rid of the second [b]const[/b]. The + operator typically is expected to [b][i]not[/i][/b] modify the [b]b[/b] object (as [b]vijayan121[/b] explained with [inlinecode]a = b.operator+(c) … | |
Re: Take a look through this thread: [URL="http://www.daniweb.com/forums/thread103675.html"]Tutorial: Handling Dates and Time in Delphi[/URL] Near the bottom there is some thoughts on [I]reading[/I] dates (which is the hard part). Writing dates is easy. Hope this helps. | |
| |
Re: Use a 2D array or a sparse matrix. How do you plan to use the graph? | |
Re: Yep, you are right. It is entirely new. The most significant help will be to keep in mind that Windows was written in C, not C++. WINAPI is a #define for the stdcall calling convention modifier. By explicitly defining the function as using the stdcall calling convention, you are free … | |
Re: The problem is here: [inlinecode]Procedure addEmployee( position:integer;var employee:WorkT);[/inlinecode] and here: [inlinecode]1: addemployee(position, employee);[/inlinecode] The addEmployee procedure increments its [I]local[/I] position variable, but it does not change the global position variable. There are two ways to fix this: 1. [inlinecode]Procedure addEmployee( [B][COLOR="Green"]var[/COLOR][/B] position:integer;var employee:WorkT);[/inlinecode] 2. [code] 1: begin inc( position ); … | |
Re: Your friend left out [B]for[/B] statements... If your Pascal program does not contain any looping constructs (loops, gotos, and recursion), then the halting problem is valid only if the program and/or the input is infinite. To consider why, think about how a Turing machine's transitions are represented. Without loops, the … | |
Re: No need to be so harsh... However, [B]mrb260478[/B], you really are asking the impossible. It can't be done in one day. You'll need at least a week, assuming you are a genius. Three or four weeks if not. I don't personally know of many online tutorials. I learned assembly from … |
The End.