1,118 Posted Topics

Member Avatar for Miyamoto

[url]http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.1[/url] (Read the whole page)

Member Avatar for Duoas
0
89
Member Avatar for savinki

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 …

Member Avatar for Duoas
0
156
Member Avatar for fusi0n423

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.

Member Avatar for Duoas
0
110
Member Avatar for scarface3288

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 …

Member Avatar for scarface3288
0
102
Member Avatar for Kob0724

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.

Member Avatar for Kob0724
0
271
Member Avatar for daviddoria

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.

Member Avatar for daviddoria
0
93
Member Avatar for Nemoticchigga

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.

Member Avatar for Duoas
0
104
Member Avatar for Jennifer84

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 …

Member Avatar for Jennifer84
0
147
Member Avatar for Nessie83

You've got the wrong forum. Click the link at the top for "Web Development" and choose an appropriate forum there. Good luck.

Member Avatar for ronniestamps
0
132
Member Avatar for shankhs

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 …

Member Avatar for Duoas
0
152
Member Avatar for benasour

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 …

Member Avatar for Duoas
0
1K
Member Avatar for gogoc

Actually, he's talking about preventing someone [i]else's[/i] program from accessing the file system. Check out your answer over at CodeGuru.

Member Avatar for Duoas
0
107
Member Avatar for Black Magic

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]

Member Avatar for n.aggel
0
151
Member Avatar for n.aggel

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; …

Member Avatar for n.aggel
0
379
Member Avatar for alikoli

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.

Member Avatar for scarface3288
0
788
Member Avatar for monstro

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 …

Member Avatar for Duoas
0
185
Member Avatar for Clockowl

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 …

Member Avatar for Clockowl
0
127
Member Avatar for noraantonia
Member Avatar for Jennifer84

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 …

Member Avatar for Jennifer84
0
580
Member Avatar for CoolGamer48

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.)

Member Avatar for Salem
0
144
Member Avatar for jagatsastry
Member Avatar for guest7

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> // …

Member Avatar for Ancient Dragon
0
108
Member Avatar for Sephy

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 …

Member Avatar for Duoas
0
112
Member Avatar for Metalsiege

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 …

Member Avatar for Metalsiege
0
203
Member Avatar for rayman341

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 ); …

Member Avatar for Duoas
0
536
Member Avatar for Najid
Member Avatar for amjadamjad20

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?

Member Avatar for Duoas
0
106
Member Avatar for guest7

[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.

Member Avatar for Duoas
0
96
Member Avatar for rayman341

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 ] := …

Member Avatar for Duoas
0
125
Member Avatar for rayman341

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; …

Member Avatar for rayman341
0
470
Member Avatar for yazooney

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 …

Member Avatar for Salem
0
138
Member Avatar for kux

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 …

Member Avatar for Salem
0
195
Member Avatar for flash121

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.

Member Avatar for bugmenot
0
137
Member Avatar for Cafetero

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 …

Member Avatar for Duoas
0
158
Member Avatar for Xyhm

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.

Member Avatar for Duoas
0
112
Member Avatar for Jennifer84

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.

Member Avatar for Duoas
0
150
Member Avatar for Aamit

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.

Member Avatar for Duoas
0
98
Member Avatar for Roofus

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 ); // …

Member Avatar for Roofus
0
2K
Member Avatar for Jennifer84

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 …

Member Avatar for Jennifer84
0
136
Member Avatar for Jennifer84

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!

Member Avatar for Jennifer84
0
181
Member Avatar for Jennifer84
Member Avatar for Jennifer84
0
119
Member Avatar for toxygen

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 …

Member Avatar for toxygen
0
94
Member Avatar for hmaich

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) …

Member Avatar for Duoas
0
120
Member Avatar for BinaryAssassin

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.

Member Avatar for Duoas
0
116
Member Avatar for sony112
Member Avatar for Duoas
0
106
Member Avatar for johnkurtz
Member Avatar for Duoas
0
66
Member Avatar for rumencho

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 …

Member Avatar for Duoas
0
123
Member Avatar for Daniel1505

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 ); …

Member Avatar for Duoas
0
130
Member Avatar for chts12345

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 …

Member Avatar for Duoas
0
171
Member Avatar for mrb260478

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 …

Member Avatar for BeR54
0
122

The End.