1,296 Posted Topics
Re: This trivial excersise (most likely it's a classic monkey job) will never improve your coding skill. I'm absolutely convinced of this. | |
Re: See [url]http://www.rt.com/man/scandir.3.html[/url] + links on this page... | |
Re: During "pre-bool period" of C++ language [icode](x || y)[/icode] was an expression of type int (not bool), as in C language. Its possible values were 0 or 1 (by definition). Probably, in [icode](x || y ) == true[/icode] expression the venerable elder (BC++ 3.1) made an attempt to convert int … | |
Re: Taking into account your previous web orientation, start from Java or C# (for Windows only). At least, you have a good chance for developing a good programming style. Of course, there are many others server-side programming web-oriented languages... | |
Re: 1. Member function call in C (in Java too?): [code=cpp] ... classvar.getHealth() // not classvar.getHealth; [/code] 2. Human is a pointer to a class, not a class var, so [code=cpp] int i = Human->getHealth(); [/code] 3. Don't include .cpp files. Place Unit class declaration only in unit.h file. Place Unit … | |
Re: In passing look at the recent thread of your colleague - young meteorologist: [url]http://www.daniweb.com/forums/thread137898.html[/url] May be it helps ;)... | |
Re: Look at this problem from the other side. Ask yourself: why I need access to the private variable of the other class? You (or the 2nd class author) declared this variable as a private one to prevent such access. For example, only the 2nd class member functions guarantee its proper … | |
Re: What's a problem? You initialize inner vectors incorrectly. Furthemore, you must take a decision for a suitable vector elements indexation (StudentNum starts from 1, but the 1st index in a vector is equal to 0). [code=cpp] int StudentNum = 1, rflds; TDataSet *Students = DSet; String stu; rflds = Students->FieldCount; … | |
Re: Moreover, visually identical functions with int and short int arguments have different compiled bodies codes and calling codes too. For example, to pass short int arg the compiler emits "push half-word" CPU instruction but for int arg it emits "load word" instruction... | |
Re: Excellent project! [code=cplusplus] class BasicDigitalLibrary { public: virtual ~DigitalLibrary() {} virtual void doIt() = 0; }; [/code] Start from the project specifications. Build use case list, for example: 1. Add a book to the library 2. ... ... N. List books borrowed to... N+1. Add a new user... ... and … | |
Re: 1. You have a binary file. Don't use getline to get data from it - getline gets a line from a text file; use read(): [code=cplusplus] unsigned char key[20]; fstream f(".....",ios::binary); // No need to open file explicitly // when the filename is specified in the constructor. if (f.is_open()) // … | |
Re: There are hash_map and hash_set containers in Visual C++ (based on SGI implementation). See also: [url]http://code.google.com/p/google-sparsehash/[/url] (yet another hash containers templates, downloadable and well-documented). Look at a rather good hash function for raw bytes data (this link turned up just at the right moment;)): [url]http://www.myserverproject.net/doc/source/hash__map_8cpp.html[/url] The last (but not least) … | |
Re: ...then ask your teacher to divide your homework grade by 2 and send the second half to the author of the best answer... | |
Re: Well, it seems you have a problem. This is not enough: what and where is a problem?.. | |
Re: See "The Design and Evolution of C++" by B.Stroustrup, 3.7 (exactly your situation as an example of initial references incorrectness). Obviously, Turbo C++ implements the initial version of C++ references (without later restriction not to bind non-const refs to const objects). It's not a safety toy... Well, so many good … | |
Re: Yes, of course. But are you ready to get a fraction looks like [quote] 1/(2*1021) - denominator is an integer number with ~308 digits [/quote] ? See <float.h> header, DBL_MIN_EXP and DBL_MIN definitions... | |
Re: Alas, your program has too rigid architecture including disposable functions with incorrect logic. Why do you write all functions without parameters? As far as I know, your task assignment includes a phrase "with a proper parameters" (or what else). Why these functions process global data only? Let's consider your indexHighTemp … | |
Re: Regrettably, in practice no way to measure time intervals with better than ~15 MILLIsecond precision in platform-independent manner (i.e with C RTL functions including clock()). The CLOCKS_PER_SECOND macros per se does not guarantee that your program may catch every tick with this frequency. I don't know what's your target platform. … | |
Re: If you want a real 3D array C++ surrogate then try indicies, not iterators: [code=cpp] // int base for simplicity typedef std::vector<int> int1D; typedef std::vector<int1D> int2D; typedef std::vector<int2D> int3D; int main() { int dim = 3; int3D v; // initiate the cube so v[i][j][k] == ijk... v.resize(dim); for (int i … | |
Re: It's a good day (or night) to quote the C++ Standard: [quote]8.3.2 References ... 4 There shall be no references to references, no arrays of references, and no pointers to references. [/quote] So I have a profound respect for IBM: they know generally known truth... Well, another quote: [code=cplusplus] int … | |
Re: Shooting Yourself in the Foot story... Suppose you have [icode]toolNameString.length()[/icode] is equal to 40 (too long for toolName char[20] array). Now see your code with /// added comments: [code=cpp] // copy at most 20 characters for the tool name const char *toolNameValue = toolNameString.c_str(); int length = int(toolNameString.length()); /// length … | |
Re: Please, present Tools class data members declarations. For example, you can't write/read an object with std::string members via low-level binary transput mechanics... | |
Re: From C++ Standard: [quote] 15.5.2 The std::unexpected() function [except.unexpected] 1 If a function with an exception-specification throws an exception that is not listed in the exception-specification, the function std::unexpected() is called (18.6.2) immediately after completing the stack unwinding for the former function 2 The std::unexpected() function shall not return, but … | |
Re: Don't waste the time for writing random pieces of codes. You have rather serious task, start from the Project Plan. You must study some theoretical issues before to start your program design. Search INET for random number generation theory and basics of statistical simulation. Wikipedia is a good start point … | |
Re: Don't worry, it's not an error: it's a VC++ warning. Ignore it (in this case). See notes in MSDN help page on this function (click strncpy then press F1). | |
Re: Some linguistic studies in Serialization ;): From [url]http://www.yourdictionary.com/serialize:[/url] [quote]serialize Definition: to put or publish (a story , etc.) in serial form[/quote] From [url]http://www.merriam-webster.com/dictionary/serialize:[/url] [quote]serialize: to arrange or publish in serial form <serialize a novel>[/quote] [quote]serial: ... 6: relating to or being a connection in a computer system in which the … | |
Re: The most intriguing question on this forum: how pupils did their homeworks in pre-Internet era? In the "1st method" you had incorrect, erratical behaviour: you get strlen(s) where s is not initialized (then overwritten with your program char by char input). Better forget this nightmare and follow Ancient Dragon's advice(s)... | |
Re: 1. Revise your program logic. You have inner for loop which repeats 100 times without condition. After that you input a new command then repeat this senseless loop again... 2. There is a wonderful thing in C++. It called a function. Define a function to get empleado value from the … | |
Re: 1. Follow Salem's advice (better use [icode]p1 = (w1 * 100) / g1[/icode]). 2. Change the last single % in the header string literal to double %% (see printf format string specifications). 3. Better use tabs \t to adjust columns in all trailing printfs. | |
Re: Exactly as in <string.h> but all names are in namespace std. As usually, you may find all system headers in include directory of your compiler installation. | |
Re: Judging by the post, sinner has a good chances to go far... | |
Re: You have absolutely useless inner while loop. Replace it: [code=cplusplus] if (ventas_vendedor > aux_ventas) // here i have the max sells made { aux_ventas = ventas_vendedor; vendedor = 1; // Now we have one and only one leader! } else if (ventas_venderor == aux_ventas) ++vendedor; // addition to the family... … | |
Re: Answer negative. It's one of implementation-defined issues. However you may write your own double to string conversion function then use it and %s format specifier... | |
Re: Well, it's so simple. You have integers in range 2..12. Declare an array of integers with size 13 (you may use indicies from 0 to 12). Initialize it with zeroes then add 1 to [icode]array[sum][/icode] element in the simulation main loop. Use rand() with a proper scaling to get values … | |
Re: Apropos, move [icode]#include <iostream>[/icode] to <stdafx.h> from the main file. That's just what for stdafx.h exists. Place all <...> includes in stdafx.h. Place your own headers ("...") in your source file (or in stdafx.h too). Read VS help about pre-compiled headers in VC++. | |
Re: Never write objects with std::string members (see furnished) in address-sizeof style. It's wrong to write (and read) individual std::string type members with this C-like mechanics. The size in bytes of std::string ([icode]sizeof(std::string)[/icode] is well-defined and CONSTANT value. It does not include true size of contained text. The pointer to std::string … | |
Re: Don't waste the time, you live in C World now: [code=c] ++array[indexNum]; [/code] | |
Re: Some additions: 1. Of course, all four declarations are legal in C++ (I prefer the simplest 2nd - it's the only form in pure C++ w/o C++ library headers ;)). C++ (pre)Standard (4.1): [quote] A null pointer constant is an integral constant expression (5.19) rvalue of integer type that evaluates … | |
Re: Is bmp font == pixel font? If so, I think it's impossible automatically convert pictures to True Type font. The last one is not only character glyphs but really a special program for rendering fonts with different rasters and sizes. There are tons of utilities (of course, libraries too) which … | |
Re: As far as I know, SQLCHAR is a typedef for [icode]unsigned char*[/icode] (or [icode]signed char*[/icode] in other versions). If so, use brutal force method (in C style): [code=cpp] strcpy((char*)szString,"Let's Try This!"); [/code] | |
Re: 1. Try [url]http://www.meangene.com/notes/time.html[/url] 2. As usually, time_t returned from time(...) is in seconds, not milliseconds. 3. Use code and /code tags to present your codes. | |
Re: Some notes: 1. Never use float for math calculations (as in original post). Use double type only. 2. Try to avoid factorial function calculations (especially as integer). This function has too fast growth. 3. Try to use recurrent dependiences. For example (it's not ideal solution, of course): [code=c] double sinRough(double … | |
Re: 1. Please, correct code indentation before send the code next time. 2. Your program performs two absolutely identical actions for Filip and Jimi cases. Why? | |
Re: Good news: std::string has a wonderful member function c_str(). It returns a const pointer to the C-style version of the invoking string. Now you may use all power of old good str family. Don't modify the string contents via forcibly casted as non-const pointer obtained from c_str()! | |
Re: All STL classes are declared in namespace std. Open namespaces with [icode]using namespace std;[/icode] or use fully qualified name as [icode]std::queue[/icode]. | |
Re: The only way to search in std::vector - scan the vector with iterator (from begin() upto end())) and compare search string with (*iter)->name. If you want fast (better than linear) search, see std::map class with find member function. Apropos, it seems you need [icode]delete *iter;[/icode], not [icode]delete (*iter)++;[/icode]. See what … | |
Re: Allow me to introduce my version of The Pointer Manifesto: 1. Pointers increase the efficiency of my programs 2. Pointers improve reliability of my C++ programs due to its flexibility, natural semantics and paragraph #1 issues | |
Re: As usually in C and C++, typedef lends a helping hand: [code=cpp] typedef std::vector<std::string> String1D; typedef std::vector<String1D> String2D; typedef std::vector<String2D> String3D; // Now slightly terrible construct for judges of a vector as a true array surrogate: String3D s3d(2,String2D(2,String1D(2))); // End of nightmare. Now we have 2x2x2 matrix (of strings?)... s3d[1][1][1] … | |
Re: 1. Where is enum food type values or variables in the snippet? Why "error Using Enum type and loops"? 2. If cin >> user_selection failed (for example, type a letter), you never break loop. [code=cpp] if (cin >> user_selection) { // OK, continue } else { // cin is in … | |
Re: Don't worry: no revolution in C++ syntax and semantics. For example, NxPublicClass is a macros defined in NxOgrePlatform.h header. It substitutes sacramental [icode]__declspec(dllexport)[/icode] if the code compiled as DLL. Ignore it if you want to understand this code semantics only. Obviously, NxNew is a macros (with parameter) too. I don't … |
The End.