1,296 Posted Topics
Re: Look at the trailed backslash: [code=cplusplus] // Test constructors\ Complex c1, c2(6.35), c3(-5.5, 3.0); [/code] It's a continuation-line character in C and C++. The next line now is a part of a single-line comment, so you don't declare c1, c2 and c2 variables! The 2nd error is hidden (for the … | |
Re: Use atof instead of atoi. | |
Re: It's Ubuntu g++ (old) problem. Better ask help on Ubuntu forums... | |
Re: The special pointer [icode]this[/icode] has type [icode]Class*const[/icode] (not Class*) so you can't pass [icode]this[/icode] as an argument to myFunction. It seems the myfunction member has a slightly unusual signature with the 1st parameter of type "a reference to a pointer to myClass<temp_Type>". Can you explain what do you want to … | |
Re: It seems now this thread looks like a horrible mash of valued receipts and consumate gibberish advices. You can't use windows.h header with aged 16-bit Turbo C++ 3.0 compiler. You can't use goto statement to jump into the main function from outside its body. You can't do the simplest thing: … | |
Re: Good idea. Optimized solution (to have a star easely, faster with factor 10 or more): [code=c] printf( "*\n" "***\n" "*****\n" "*******\n" "*********\n" ); [/code] Premium edition for lazy programmers... | |
Re: Some additions: 1. If no returned type explicitly defined in C and C++, int assumed (backward compatibility with Stone Age of the C language). Of course, now it's bad style. 2. Effect of input stream fflush is not defined in the C language. 3. Declare name and dep members as … | |
Re: Please, don't waste your time on these unintelligible posts. Look at [url]http://www.daniweb.com/forums/thread78223.html[/url] | |
Re: Congratulation! You ignore all this forum rules: [url]http://www.daniweb.com/forums/thread78223.html[/url] | |
Re: I think it's a problem with your understanding of the std::vector class properties. Before using v[10] you must initialize v[10] vector element. For example, you can declare [icode]std::vector<type> v(N)[/icode] or call [icode]v.push_back(something)[/icode] at least N times or call [icode]v.resize(N)[/icode] where N >= 11. | |
Re: Your Windows installation does not know where is the g++ executable. See [url]https://users.cs.jmu.edu/bernstdh/web/common/help/cpp_mingw-faq.php[/url] | |
Re: Look at [url]http://en.wikipedia.org/wiki/Triangular_matrix[/url] | |
Re: There is a wonderful choice in VS 2008 File menu: File|New|Project From Existing Code... Always specify Visual Studio version if you want help on IDE... | |
Re: The for statement syntax: [code] for (for-init-statement condition(opt); expression) for-init-statement:: expression-statement simple-declaration expression-statement:: expression(opt) ; [/code] Informally simple-declaration is well-known type names-with-possible-initializators construct. The semicolon token terminates construct in C++. Obviously, [icode]int i = 0, int j = 0;[/icode] and especially [icode]int i = 0, double d = 1;[/icode] are … | |
Re: Well, go to Java basics then go to C# basics... What's a pleasure to live in the city where no buildings, foundations only... ;) | |
Re: About this thread starting question: look at my posts in solved threads (two month ago): [url]http://www.daniweb.com/forums/thread136351.html[/url] [url]http://www.daniweb.com/forums/thread137814.html[/url] | |
Re: Use outtext or outtextxy functions. Prepare a text string with [code=c] char text[80]; /* */ ... sprintf(text," sum = %d",x); outtext(text); [/code] See BGI functions manual. Online version for extended BGI: [url]http://www.cs.colorado.edu/~main/cs1300/doc/bgi/index.html[/url] Search Google for more info. | |
Re: Yet another orphan post (see [url]http://www.daniweb.com/forums/thread148725.html[/url] - 3 hours later). Alas, the post header does not bear a relation to the true problem (as in the 2nd thread too ;)). Don't forget to mark this orphan as solved too when you will get an answer to the 2nd thread (better … | |
Re: Look at the statement: [code=cplusplus] outFile << aa << endl; [/code] <<endl prints newline and flushes output buffer. That's why your program prints every char on the new line... | |
Re: Regrettably no background demons which capable to trace your Selection_sort array elements shuffling. You must change Selection_sort code to assign not only elements of processed array but also synchronously move its initial position in "parallel array". Add 4th array parameter to Selection_sort function (and add corresponded temp variables for pivot, … | |
Re: You don't pass "char by reference" to these functions. You pass (as usually by value, not by reference) a pointer to char: feel the difference. Look at "pass char by reference" case: [code=cplusplus] void PassCharByRef(char& c); [/code] Don't mix distinct types: array of char and char. About array case: there … | |
Re: It's funny that you program prints anything: the only purpose of this code now is the program stack corruption. The 1st index in C and C++ arrays is 0 (not 1!). All for loops in your input routines are wrong. See also finalgrade function: not all control paths return a … | |
Re: 1. Better follow standard pow pattern: use double type for argument and returned value. 2. Some useful method: extract recursive part to reduce a number of operators in recursion: [code=c] static double powrec(double x, int n) { return n? x * powrec(x,n-1): 1.0; } double powint(double x, int n) { … | |
Re: See, for example: [url]http://www.eldar.org/~ben/convert/c_f.html[/url] but don't forget: you must use double arithmetic and constants ;). | |
Re: It seems your Cells class looks like a harmless caricature of OOP. The file name is a hidden builtin string literal, grid parameters depends on module scope constant int values, the only interface member function unexpectedly prints to cout builtin and rigid messages (I want to count only, not to … | |
Re: What's a funny thing - decimal rounding of binary floats... May be it stands in good steads ;): [code=c] /** * 2008-10-01 Beta version. No warranties... * Rounding functions freeware mini-package. * About rounding forms and MS rounding stuff * see http://support.microsoft.com/kb/196652 * Dependencies: <math.h> <float.h> * Languages: standard C … | |
Re: How funny: the grade_equivalent function performs a long chain of if-elses to get an exact floating-point equivalent of grade then return integer value! And where is your 1.25, 1.75 and other non-integer values after that? Moreover, grade_equivalent(75) == 3 but it returns 5 for 76, 77 and 78... | |
Re: It's impossible to compile this code: [icode]char binary[ElementAmount];[/icode] declaraion where ElementAmount is not initialized variable is wrong. Post another "0 warning 0 errors" snippet ;)... | |
Re: What's a hot thread!.. I don't know why you want to copy vector contents into dynamically allocated array. I think it's not so good idea: you get a new pointer to the heap then have a new trouble with its deallocation in a proper moment. You always can obtain a … | |
Re: 1. Always use tag CODE to post your snippets: [noparse][code=cplusplus] your code [/code][/noparse] 2. Senseless member function does not assign any value to month: [code=cplusplus] void Month::Input(istream& in) { char first,second,third; int number_month; char c; c=in.peek(); if ( (c > '0') && (c <= '9')) { in >> number_month; Month(nuber_month); … | |
Re: No, it's absolutely illegal expression (or illegal declarator). The operator & needs lvalue argument but returns so called rvalue (of right part). In other words, the argument of operator & must be a function or an object in memory but it returns a value (not an object or a function). … | |
Re: 1. Avoid these horrible switch cascades (as in Month::Output) where possible (it's that case). 2. Don't add unnecessary dependencies in your class design. For example, your Month class is dependent of ostreams via Month::Output(). Why? Better add some useful functionalities (and see point #1 above): [code=cplusplus] const char* Month:: Name() … | |
Re: See hash_map::find description with an example: [url]http://msdn.microsoft.com/en-us/library/525kffzd.aspx[/url] About hash_map class in VC++: [url]http://msdn.microsoft.com/en-us/library/0d462wfh.aspx[/url] | |
Re: Why you include readcharacter.cpp in the "other file"? It seems you don't understand the principle of a splitting a program to separate modules. Now you have ReadCharacter function body in both modules. Of course, the linker (it's a part of your programming system: linker builds exe from separately compiled modules) … | |
Re: >you can actually calculate a more accurate solution without using a power function Probably you can do that but not with this series. You must calculate over 250 terms to achieve log(result) == 156 (slower than pow with factor ~25) but pow approximation of e^156 is better than sum of … | |
Re: As far as I know LNK1120 in MS VC gives a count of unresolved externals (LNK2019 error: unresolved external symnol found in the function...). Both errors are common. No definition for external symbol. So we can't help you with error numbers only... | |
Re: Better explain what problems you have with iterators. Do you want to invent quadrate wheels?.. | |
Re: An extremely ineffective algorithm. It has O(M*N) complexity and can't detect line swapping and line deleting and inserting... Think about better algorithm now (for example, load a file into map<string,vector<int>> or what else... | |
Re: As far as I know you need "t:" getopt option. May be I'm wrong (I don't like getopt ;)). See [url]http://www.gnu.org/software/libtool/manual/libc/Using-Getopt.html#Using-Getopt[/url] | |
Re: Thank you all participants for a very interesting discussion in the thread. Some additions: Let's remember what is a copy constructor in C++. Copy constructors are (C++ Std, 12.8): [quote]A non-template constructor for class X is a copy constructor if its first parameter is of type X&, const X&, volatile … | |
Re: Regrettably I have no time now to inspect your code more carefully but your list() initialization function is obviously wrong. It does initialize nothing because of it modifies by value copies of head/tail pointers only. It must have double indirection parameters to modify its arguments. | |
Re: However take into account the C++ Standard, 3.6.2 (3): [quote]It is implementation-defined whether or not the dynamic initialization (8.5, 9.4, 12.1, 12.6.1) of an object of namespace scope is done before the first statement of main. If the initialization is deferred to some point in time after the first statement … | |
Re: I have one and only but brilliant idea: get your textbook and read about: 1. Hexadecimal int and char literals (0xBC and '\xBC', for example). 2. Shift operators << and >> 3. Logical or/and operators | and & That's all, folks... | |
Re: The only addition to Ancient Dragon's C stream library method: add setvbuf call after fopen: [code=cplusplus] const size_t BSZ = 1024*32 // or more ... FILE* fp = fopen("..\\TextFile1.txt", "r"); if (fp) { setvbuf(fp,0,_IOFBF,BSZ); // No need to free buffers explicitly ... [/code] Default stream buffer size is too small … | |
Re: Because of no total linear memory space concept in platform-independent C++ language. Moreover, no assumption that pointer binary representations are positive (or negative or even if they are valid) integer values. For example, visual pointer representation on some platforms looks like XXXX:YYYY - is it integer? You can use reinterpret_cast<> … | |
Re: Look at your class constructor: [code=cplusplus] jStack<T>(T* element) { LinkedNode<T> node(element); top = &node; count = 1; } [/code] Now what happens: you create LOCAL (in the stack) variable node and place its address (the pointer to local node var) in the top pointer (don't forget: a constructor is a … | |
Re: Hmm... Many years ago I have implemented a complete POS system for a very good POS terminal in Turbo C 2.0... ~30000 lines of source codes... ~3 month of 24/7 works... | |
Re: Of course, you can compare minutes and seconds but it's senseless operation. For examples, you have 10 dollars and I have 11 cents. Let's compare our capitals... OK, 11 > 10 - I'm so reach, poor chern4ever... You can properly compare values of [icode]60.0*minutes + seconds[/icode]. | |
Re: Alas, you write itoa result to nowhere. Just before itoa call YOU say: my hexData pointer points to NOWHERE (NULL is this NOWHERE). You must pass a real memory pointer to itoa. Declare a char array or allocate memory chunk by new operator. Or (better) reread your C or C++ … | |
Re: Copy/paste all commentaries from the source: it's your desired pseudocode ;)... |
The End.