- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 80
- Posts with Upvotes
- 69
- Upvoting Members
- 35
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
420 Posted Topics
Re: Anyone who's ever seen Die Hard With a Vengeance should remember the answer to this one.. If you haven't seen the film, see if you can work it out in 30 seconds ;) [QUOTE]A man was going to St. Ives.. He met a man with seven wives.. Every wife had … | |
Re: Your code is difficult to read - try adding some formatting! a few points to note 1) Why is there a semicolon before int main() ? Presumably its supposed to belong to the function prototype 2 lines up - you should put it there instead, else it just looks like … | |
Re: One of the biggest problems with C++ books older than 1999/2000 is that they do not recognise alot of modern Standard C++ content. A problem commonly found with "revised" books after 1999/2000 (Books which were originally published long before C++ was standardised, but have been updated) is that the Standard … | |
Re: I wouldn't call 2 a special case - it fits the general description perfectly; [I]A number evenly divisible only by 1 and itself.[/I] :) | |
Re: That's a totally nonsensical question, what are you trying to do? Machine code is the very low-level instruction set that your computer's processor uses. Are you looking to learn how to program in an assembly language? | |
Re: In general, the steps to getting MSVC++ 2005 to work should be something along the lines of - Create a new Solution, using a Win32 Console Project - Right-Click on the project's name in the solution explorer, choose properties. - In the Configuration Properties Window, look for the option to … | |
Re: [QUOTE=Ancient Dragon]Using Microsoft compilers, I am not at all convinced that std::cout is faster than printf(). I have made similar tests in the past on other computers with M$ os and have never seen one where cout is faster than printf(). And I would be supprised if *nix computers was … | |
Re: You can't in standard C++ [url]http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.20[/url] [url]http://www.cprogramming.com/faq/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385[/url] | |
Re: Tell your school that you are unhappy about being taught using obsolete technology. Turbo C++ has no place in today's world, and insist that they provide you with an education which is relevent - i.e. by teaching you using modern material which works on modern compilers. | |
| |
Re: Also, I would consider any code which attempted to automatically delete anything from my machine (whether it were browser history or otherwise) without my permission as malicious code. Your intentions may not be malicious, but you should seriously think about how users of your website are going to react. You'll … | |
Re: fgetc is a C function. The C++ way to do it is [CODE=cpp]char ch = std::cin.get() [/CODE] | |
Re: The [icode]>>[/icode] operator is whitespace delimited by default when used with any kind of stream; including cin, fstream and stringstream; so you can use that to your advantage to turn a stringstream into a simple tokeniser e.g. [code=cpp]#include <string> #include <sstream> #include <iostream> [/CODE] ... [CODE=cpp]std::istringstream hello("the cat sat on … | |
Re: It's a little bit vague, but I think it depends exactly on what your code currently does and how much those objects have got in common (more importantly, how much your initialisation code has got in common) Are you currently implementing this using a lot of repeated code? If so, … | |
Re: Short Answer: No. Long Answer... You only need to [b]delete[/b] something if - You created the object using [b]new[/b] (or you used some other library or function which created it with [b]new[/b]) - You own the object (i.e. it is not owned by a smart pointer or another class from … | |
Re: Here, you have declared a variable called [icode]ptr[/icode] [QUOTE=faraz ahmad;1762882][code] void question1() { int i=0; int* ptr=nullptr; [/code][/quote] Here you are declaring a completely different variable, which also happens to be called [icode]ptr[/icode] and hides the variable you'd previously declared by the same name.[QUOTE=faraz ahmad;1762882][CODE] while(boolean!=false) { cout << "Enter … | |
Re: [QUOTE=personathome;1762325] it either puts out c or some random number. Also I can not use isdigit unfort. [/quote] [CODE] char c = ch; if(c>=48&&c<=57) cout << 'c' << endl; [/CODE]A character inside single-quotes denotes a character value, so all you're doing here is printing out 'c'. This value has absolutely … | |
Re: [QUOTE=kikic;1762284]I must not use finite function like that you write me,I need to write function step by step which works for alphabetic sorting in C++...[/QUOTE] Ancient Dragon's other suggestion was to do a google search for [i]Bubble Sort[/i] - try that and you will get plenty of good links which … | |
Re: You're misunderstanding somewhat. It is not possible to simply resize a 'raw' array (Whether it is created by [b]new[/b] or as an ordinary array object). Once an array is created in memory, it can't be extended - The reason being that you have no control over the layout of objects … | |
Re: [QUOTE=gampalu]This program works... I don´t know if it's like this that youi want: //snip[/QUOTE] Most probably not! choose a language, either C or C++, and stick to it.. mixing the two like that is really a very very bad idea. | |
Re: operator<<() is a member function - you can only pass one parameter at a time to your Stack object using operator<<() - eg, [CODE]Stack myStackObj; myStackObj << SomeValueHere;[/CODE] If you are merely trying to overload operator<<() then it should be a non-member function. When defined as a member, the object … | |
Re: That depends what the program is. I doubt that he's asking you to rewrite the sqrt, log and pow functions from math.h (Unless your course is a mathematics one). if you post a description of your problem, and the code from your current solution, there might be another way to … | |
Re: Are you asking for reviews? I don't own the book, but I am aware of its existance, and its outdated approach to teaching the language. C++ primer plus is an old book which was "updated" after C++ was revamped and standardised; unfortunately, when C++ was reborn as a new language, … | |
This code snippet outlines a simple, no-frills linked list. Tested under MSVC++ 2003 and Comeau, but not guaranteed bug free. Snippet includes example main() . This snippet is intended as an example of a possible implementation of a linked list class (Of which there are many variations) For a better … | |
Re: Mainly because of an observation by Edsger Dijkstra in 1968, where he argued "GOTO Statement Considered Harmful" (Google it and you'll find copies of the white paper) In brief, the observation is that (In general), the number of 'goto' statements a programmer uses in their code is inversely proportional to … | |
Re: if [inlinecode]Node[/inlinecode] is a template class, then the way to create an object is to specify the type you want inbetween < and > [CODE=cpp]Node<int> my_int_Node; Node<double> my_double_Node; Node<bool> my_bool_Node; //etc. [/CODE] | |
Re: First of all, I suggest taking a look at the short tutorial on random numbers here - [url]http://www.daniweb.com/tutorials/tutorial1769.html[/url] | |
Re: Bearing in mind that if this is a console application, there's a finite number of characters for any given line which you can output without the code spilling over to the next line, and completely ruining your formatting anyway. Therefore, it may be simplest to put in an upper limit … | |
Re: These aren't examples of quines though - To qualify as a quine, the program must be able to replicate its own source code [U]without[/U] any input (either from a file, the keyboard, or anywhere else) see here for a little more info [url]http://en.wikipedia.org/wiki/Quine_%28computing%29[/url] | |
Re: I don't know how many others do this, but I've often found myself drafting replies to problems which people have posted, but not actually sending my reply straight away. On many occasions, i've kept the reply in a notepad document, and ended up deleting them, if I think i'm wrong. … | |
Re: [QUOTE=Narue;464574] It strikes me that your problem is confidence, and the best way to build confidence is to jump right in. Do something, anything, even if it turns out to be wrong. As it is you'll spend all of your time second guessing yourself and then you'll come to us … | |
Re: In answer to the subject line - 'how does recursion work'. Recursion causes a new function call to be pushed onto your call stack. You may visualise it procedurally as a function which calls a function which calls a function etc. For example, an un-rolled "factorial" function would look like: … | |
Re: Everything which you learn from a book written in the past 10 years will be equally relevant long after C++0x becomes the accepted standard. Equally, however, there's nothing at all which stops you using a compiler which supports some C++0x features; its never a bad idea to learn using the … | |
Re: [QUOTE=Salem;405240]Put the single character into a short string. Easy isn't it?[/QUOTE] ... [QUOTE=krnekhelesh;405530]yeah but the thing is everywhere I had used a char variable, so it would be difficult changing them all. Anyway I got an idea. I will copy the contents of the char to a string. And then … | |
Re: What exactly do you mean by [i]rules[/i]? There are no [i]rules[/i] for Coding style - such coding standards are usually based upon one or more of: [list] [*]Personal Preference [*]Conventional wisdom (i.e. what do 'most other people' do?) [*]Consistency with existing code (If you're modifying someone else's code) [*]Style imposed … | |
Re: I've heard a similar one to that before - [QUOTE]Success in mathematics is 90% perspiration and 20% inspiration[/QUOTE] One of my usenet and e-mail signatures for a very long time - [QUOTE]"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in … | |
For anyone who gets fed up with the somewhat verbose syntax involved in populating an STL map container with static arrays of std::pair (Or any of the other somewhat tedious ways of writing 'pair' combinations), here is a function which allows two different (statically allocated) arrays, of equal length, to … | |
Re: Is it that time of year when students have 6-month-long projects to start with 3 days remaining? :P | |
Re: Oh this is sombre news indeed. I would like to add my name to the end of the long list of people who really appreciated Dave's bold presence on Daniweb; in all the time I've spent lurking around these forums, his many contributions here never ceased to feel enlightening ro … | |
Re: Are you sure you've actually got an internal speaker? Not all motherboards have a connector for it. (Does your computer make a beep when you turn it on..?) | |
Re: Why are you even using [b]char*[/b] instead of the standard [i]string[/i] type anyway? | |
Re: Did you try asking [URL="http://www.google.com"]Google[/URL]? | |
Re: I find the argument about simplicity to be somewhat perplexing - C++ and Java have amazingly simple syntax rules when compared to any natural language. I reckon you could summarise the fundamental syntax of most programming languages using a handful of sheets of paper; on the other hand, natural languages … | |
Re: 'eof' is a flag on a stream; it signals that a failed read attempt to read past the end of a stream has occurred, in other words, by the time your loop comes to find out that the stream has failed, a complete iteration of that loop has already tried … | |
Re: Why would you want to pre-allocate memory for a linked list? If you want to do that, you may aswell use a vector (or a deque). | |
Re: The fact that you have so many errors suggests to me that you need to start afresh, and create your program one bit at a time [i]slowly[/i]. Don't write 100 lines of code without trying to compile it, write a few lines at a time, or one small function at … | |
Re: Please provide more detail; Does your program compile successfully? If not, then please post the compiler errors/warnings; If so, what happens when you run your program, and how does this differ to what you're expecting? | |
Re: things like 'game', 'player', 'room', etc don't sound particularly abstract to me :-) Usually when I think about [i]concepts[/i], the initial question is "what does the program [b]do[/b] - i.e. rather than considering the program as a bunch of uninteresting static objects, think about the interactions between them, especially in … | |
Re: what exactly is REGISTER_BUILDER? are you 100% sure that its a function? usually ALL_UPPERCASE names are reserved exclusively for #define macros it would help a great deal if you could show us the definition of REGISTER_BUILDER. | |
Re: the [icode]::[/icode] symbol is known as the [i]Scope Resolution[/i] operator because it is used to specify the scope in which an identifier resides within your program; The concept of 'scope' generally applies anywhere that curly brackets can be found [icode]{ }[/icode] - the reason for the concept of scope is … |
The End.