1,296 Posted Topics

Member Avatar for tootypegs

This trivial excersise (most likely it's a classic monkey job) will never improve your coding skill. I'm absolutely convinced of this.

Member Avatar for mitrmkar
0
108
Member Avatar for richM
Member Avatar for richM
0
47
Member Avatar for NickyU

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 …

Member Avatar for NickyU
0
249
Member Avatar for usedcars

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

Member Avatar for ArkM
0
105
Member Avatar for delsigno

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 …

Member Avatar for delsigno
0
104
Member Avatar for Ccrobinson001

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

Member Avatar for Ccrobinson001
0
4K
Member Avatar for williamnz

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 …

Member Avatar for William Hemsworth
0
395
Member Avatar for MrGobroski

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

Member Avatar for MrGobroski
0
171
Member Avatar for abhisdm

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

Member Avatar for ArkM
0
153
Member Avatar for REJARR

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 …

Member Avatar for ArkM
0
84
Member Avatar for adamj2

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

Member Avatar for ArkM
0
177
Member Avatar for complete

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

Member Avatar for ArkM
0
111
Member Avatar for dummy programer

...then ask your teacher to divide your homework grade by 2 and send the second half to the author of the best answer...

Member Avatar for dummy programer
0
72
Member Avatar for QuantNeeds

Well, it seems you have a problem. This is not enough: what and where is a problem?..

Member Avatar for Ancient Dragon
0
320
Member Avatar for Prabakar

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 …

Member Avatar for Prabakar
0
151
Member Avatar for piods

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

Member Avatar for ArkM
0
133
Member Avatar for 2fac323

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 …

Member Avatar for ArkM
0
522
Member Avatar for monjuri

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

Member Avatar for ArkM
0
152
Member Avatar for Lukezzz

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 …

Member Avatar for ArkM
0
2K
Member Avatar for kneiel

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 …

Member Avatar for kneiel
0
133
Member Avatar for QuantNeeds

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 …

Member Avatar for ArkM
0
83
Member Avatar for QuantNeeds

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

Member Avatar for ArkM
0
70
Member Avatar for kux

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 …

Member Avatar for kux
0
107
Member Avatar for wenny86

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 …

Member Avatar for ArkM
0
2K
Member Avatar for QuantNeeds

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

Member Avatar for QuantNeeds
0
1K
Member Avatar for henpecked1

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 …

Member Avatar for ArkM
0
2K
Member Avatar for Motvel

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

Member Avatar for Motvel
0
153
Member Avatar for gispe

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 …

Member Avatar for gispe
0
84
Member Avatar for plike922

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.

Member Avatar for Ancient Dragon
0
122
Member Avatar for brk235

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.

Member Avatar for ArkM
0
73
Member Avatar for sinner
Member Avatar for ArkM
0
78
Member Avatar for gispe

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

Member Avatar for gispe
0
103
Member Avatar for lehe

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

Member Avatar for ssharish2005
0
112
Member Avatar for cmatos15

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 …

Member Avatar for cmatos15
0
2K
Member Avatar for gispe

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

Member Avatar for ArkM
0
93
Member Avatar for tapaditap

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 …

Member Avatar for ArkM
0
110
Member Avatar for rob_xx17
Member Avatar for ArkM
0
116
Member Avatar for CoolGamer48

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 …

Member Avatar for ArkM
0
322
Member Avatar for CoolGamer48

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 …

Member Avatar for ArkM
1
145
Member Avatar for Frederick2

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]

Member Avatar for Frederick2
0
323
Member Avatar for kriscbe

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.

Member Avatar for Salem
0
244
Member Avatar for sasikala123

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 …

Member Avatar for stewie griffin
0
3K
Member Avatar for robertmacedonia

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?

Member Avatar for Wiki_Tiki
0
202
Member Avatar for coveredinflies

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()!

Member Avatar for CoolGamer48
0
4K
Member Avatar for Nemoticchigga

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

Member Avatar for ArkM
0
136
Member Avatar for Pikachumanson

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 …

Member Avatar for Pikachumanson
0
263
Member Avatar for kneel

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

Member Avatar for oliver_mk
0
66
Member Avatar for Lukezzz

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

Member Avatar for Nick Evan
0
2K
Member Avatar for greyghost86

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 …

Member Avatar for CoolGamer48
0
118
Member Avatar for pastryman

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 …

Member Avatar for ArkM
0
129

The End.