420 Posted Topics
Re: There was a thread on another forum a few days ago about Linked Lists, give it a read, because the answers might help you. [url]http://cboard.cprogramming.com/showthread.php?t=78460[/url] | |
Re: Have a look at this tutorial on functions; [url]http://www.cprogramming.com/tutorial/lesson4.html[/url] | |
Re: Something tells me you've found someone else's code, and you're attempting to use it without having a clue what it actually does. I hope this isn't your homework ;) [QUOTE=some one] Studio\MyProjects\delete_v\delete.cpp(670) : error C2660: 'insertArc' : function does not take 1 parameters[/QUOTE]The compiler is telling you that you've called … | |
Re: [QUOTE=cscgal]<offtopic>When I was in school, I was hanging out in the Computer Science Student Lounge when a professor walked in to get a soda out of the vending machine. Then, he exclaimed he had this great idea to give the first year students a project with vending machines and we … | |
Re: The answer is "that depends" - you have to think about how you want to go about making the program - there's no right or wrong answer, because it depends largely on how simple or complicated your program will be. Entities such as Mine or Board are fairly important to … ![]() | |
Re: [QUOTE=worms707] I get the following error: error C2451: conditional expression of type 'std::fstream' is illegal [code] if (outf1) { char ans; [/code] [/QUOTE] You can't do that with a std::fstream - however, you [b]can[/b] do it with an ofstream or an ifstream. It appears from the variable name, that you're … | |
Re: Not without seeing how [I]emp[/I] or [I]firstname[/I] are declared. it would appear from the error that [I]emp[a].last[/I] is of type [COLOR="Blue"]int[/COLOR]. Can you post more complete code? | |
Re: [CODE]int main() { COseba novi; novi.setNumber(5,3); novi.Sestej(); novi.Izpisi(); [COLOR="Red"]COseba();[/COLOR]//::COseba(); novi.Izpisi(); return 0; }[/CODE] a lone call to the constructor won't do anything useful - a constructor call means a new object is created (and in the case above, the object is created, does nothing, then destroyed) change that line to … | |
Re: Ugh! There's no way on earth anyone is going to even try to look at that code - try to format it properly. the very least you can do is [B]not[/B] have it all on one continuous line. | |
Re: an MS-DOS Program runs in DOS, and a Windows program runs in Windows. which one you create depends on your compiler and/or settings, but from a C++ perspective, there's no difference | |
Re: look up <time.h> - it includes a data type time_t - however, that is only accurate to a second AFAIK. if you need anything more accurate, you'll need to create your own, or find a 3rd party library. | |
Re: Do you mean have 2 different files simultaneously attached to one stream? No, that couldn't possibly work - how would your program know which file to read? You can, of course close one file, then reuse the same stream to open a different file - but if you need them … | |
Re: My mind-reading device isn't working today - what are you actually trying to do with the constructor? Construct a Staff object using an existing vector<Employee> ? Construct it using a single Employee object? Make a copy constructor..? Construct it using some other value..? Bear in mind that the syntax of … | |
Re: [QUOTE=tuannie]If I was to use && wouldn't that only work if all the information contain in the text file as to be a, b, c, and d for the if statement to run? [/QUOTE] No, you're reading the statement wrongly, that "if" statement says "If input isn't 'a', AND input … | |
Re: This sort of boolean arithmetic is probably simplest with a recursive algorithm. for the integers, a and b.. Take a temporary 'carrier' number which records the result of [INLINECODE]a AND b[/INLINECODE] bit-shifted one place left. if the carrier evaluates to zero, the result of the calculation becomes [INLINECODE]a XOR b[/INLINECODE] … | |
Re: You can take advantage of the fact that you can rearrange a 3x3 grid so that all horz/vert/diag lines create a sum of 15 [CODE] 2 9 4 7 5 3 6 1 8 [/CODE] This gives you a much firmer ground to perform mathematical checks on lines, for both … | |
Re: [QUOTE=Salem]3. [CODE]for([COLOR=DarkRed]int polygon[/COLOR] = 0;polygon < 3;polygon++)[/CODE] This doesn't compile - polygon isn't declared. Try to post what you actually compiled. [/QUOTE]was that a slip of the brain? or are you working in C90 mode today? :) | |
Re: the STL has built-in functions which will help you with most of that, read up on vectors, and see how some of the overloaded operators for vector work. also, look at the <algorithm> header. | |
Re: the escape character for a backslash is simply \\ - however, as Ancient Dragon says, CD\\ (or indeed any system() call) is unsafe. IIRC, chdir() is part of windows.h or conio.h depending on your implementation - it's not a standard header, but it's certainly better than system(). ![]() | |
Re: [QUOTE=Acidburn]yeh it appears to be does it not?[/QUOTE]No, it's very wrong. string::find() is a function.. I very much doubt that line is doing what you expect. Also, "$" is not a char, it's a const char* - double quotes mean a null-terminated string, wheras '$' is a single char. Although … | |
Re: Your SodaCan class needs a constructor to assign something to the private height and radius data members. eg, the line [CODE]SodaCan can(10,5);[/CODE]requires a constructor which looks like[CODE]SodaCan::SodaCan(int, int)[/CODE] Much in the same way that, for an library type, such as [I]std::string[/I] you can say [CODE]std::string s("Hello");[/CODE]which will initialise [b]s[/b] with … | |
Re: [QUOTE=tuannie]Can you provide me with another example working out so that I can use the example question and try get an understanding out of it and attempt on my quesion. Thanks in advance....[/QUOTE] You should really pick up Salem's point about decimal - Just imagine you're going back to infant … | |
Re: [QUOTE=almared_6]ya that's ok with me, but how do I get a record with the smallest? That's the question that I'm trying to find an answer for.[/QUOTE]How would you do it in real terms? Imagine someone calling out bingo numbers, and you're looking out for the smallest. The first time he … | |
Re: [QUOTE=totalnewb++]Hello all, Thank you ahead of time if anyone answers this. I am new to c++ and am having some difficulty understanding my assignment. I wrote some code that does what the teacher has requested but according to her it does not utilize a function. I know that I have … | |
Re: [QUOTE=grunge man]NOPE NOT BROKEN I DONT CARE IF I USE CORRECT GRAMER ONLINE AS LONG AS IT GETS THERE AND THE PEOPLE CAN READ[/QUOTE]There's no need to shout either. You might think that spelling & grammar are superfluous online, but if people have to first decypher your message to understand … | |
Re: What kind of partition function are you using? does "G" appear before "F" in the alphabet? | |
Re: A margin is just blank space around an object on a page (or a screen). Since your output goes from left to right, the only margin you care about is the left-hand margin... How would you add a margin of, say, 5 spaces to a text document in Windows Notepad..? | |
Re: [QUOTE=musicmancanora4]if they type anything less then 0 or more then 12 its an error[/QUOTE] Are you sure about that? What month is zero? ;) | |
Re: Do you mean to say that 2 of the derived classes share a member which the 3rd one does not? If so, you probably need an intermediary derived class, which contains those shared member(s) (either public or protected) - and derive the 2 "related" classes from this intermediary class. eg, … | |
Re: [QUOTE=iamthwee]>Andy, >Great Web page, I actually looked at before you even responded. That's not me or MY website. I just like it cos it's kewl :lol:[/QUOTE] You're kidding right? That's an epilleptic's worst nightmare! | |
Re: [QUOTE=nexes300]I see, that would make sense I guess...*scratch* Now Im going to have to find some way to initialize them I guess. *sigh* Function calls....unecessary function calls....ugly.[/QUOTE] I assume that this is some kind of a lookup table? How about wrapping your map inside a class, and using the constructor … | |
Re: All this use of '\0' is very C-like ..There is a much better way using C++ strings (And by the way, ignore the use of <string.h> <iostream.h> and void main() ) C++ strings have a size() function which tells you how many characters are in the string. [CODE]#include <iostream> #include … ![]() | |
Re: Compile this code.. then try changing bits of it... what happens when you modify it to some of the scenarios given in your homework assignment..? [CODE]#include <iostream> using namespace std; class duck { public: virtual void speak() { cout << "quack"; } }; class swan : public duck { public: … | |
Re: [QUOTE=iamthwee]If you spent the same amount of time doing your own homework as you do with other people's you wouldn't be using void main()[/QUOTE]I fixed your post ;) ![]() | |
Re: Your loop is trying to access outside the range of the array. Your array is size 5, that means, the elements are indexed by the numbers 0-4... yet your for loop says: [CODE]for (j = SIZE; j < i; j++) [/CODE]You need to loop from j=0 to j<SIZE also, you … | |
Re: when you "free" memory, you are deleting the object which "temp" points to, you are not modifying temp itself. What you are left with is a dangling pointer which points to some undefined part of memory, which could contain absolutely anything. you should assign the value of NULL to "temp" … | |
Re: If you're not sure about e() and f(), You probably need to ask a different question... such as "How many methods does an [b]object[/b] of class D have?" .. because then the answer is 4. :) | |
Re: Remember : every time you use the word "new" - make sure you also use the word "delete" (or better still, create a class which handles all the dynamic memory stuff).. at the moment, your program has got memory leaks! Also, change "void main()" into "int main()" (and, unless you're … | |
Re: [QUOTE=pete0] [CODE] if (d <= 31 && d >= 1 && m <= 12 && m >= 1 && y <=2006) [/CODE][/QUOTE] This was the first problem I noticed. Put your individual comparisons inside brackets. Think of each comparison as an individual expression. [CODE]if ( (d<=31) && (d>=1) && (m<=12) … | |
Re: Generally, your input.txt should go in the same place as your executable. If for some reason, this is causing you problems, or you do not know where the executable is, refer to the complete path of the txt file explicitly, for example, in DOS/Windows, you'd use [CODE]ifstream fin ("C:\\MyProgram\\input.txt"); [/CODE] … | |
Re: [QUOTE=Duke_0064]Hi, I'm new to this C++ stuff. So if anyone can help that would be nice. I have this program to generate a random number and a the user inputs a number from the keyboard to correctly guess the number that the computer randomly chooses. but the numbers are always … | |
Re: It would help if you could paste the exact error(s) - Be aware VC++ 6.0 is out of date, I strongly recommend downloading a newer compiler before you do anything else. There is definitely more than just one error in that code! It looks to me like you are trying … | |
Re: "bool" is short for "boolean" - look it up in any dictionary or computer science website. in C++, [COLOR=Blue]bool[/COLOR] is a data type for an object which accepts only [i]true[/i] and [i]false[/i] (or, alternatively, zero for false, and non-zero for true) | |
Re: [QUOTE=musicmancanora4]Hey guys i need to find out how many days there are in a particular month in a particular year. How can i start building an algorithm like that im having some trouble?[/QUOTE] Since there's no relation between the month and the number of days it contains, your best (portable) … | |
Re: [QUOTE=iamthwee]You'll have to make a few ammendments though[/QUOTE] Maybe you could change "C++ is an object-oriented programming language" to "C++ is a multi-paradigm language which supports object-oriented programming" Or am I clutching at straws there? ;) | |
Re: [QUOTE=server_crash]I can see how you might have one class and one 'driver' program, but I don't understand why you would want more than one class.[/QUOTE] My guess is that he wants one for roman numerals, one for Arabic numerals, etc. Maybe switching between the two using dynamic binding and inheritance. … | |
| |
Re: [QUOTE=Vagabond]// I'm A Noob but I hope this helps ~ any comments are welcome[/QUOTE] You [I]really[/I] need a new compiler. You're honestly not helping yourself by learning pre-standard C++ (And i'm afraid to say that pasting code like that won't help anyone else either. Even with the conio stuff removed, … | |
Re: [QUOTE=greizel]pls help me to write a program that will input a word or a sentence and display that youve inputted in a reverse form. if the word you entered is the same as the reverse one, "Palindrome" will be displayed. Otherwise,"NOt Palindrome"[/QUOTE] 2 Ways to do this - Either create … | |
Re: [QUOTE]we were introduced to classes as well. should I use a class node instead of a struct node?[/QUOTE] "struct" and "class" in C++ are actually the same thing with one very subtle difference - "struct" defaults to all members public, "class" defaults to all members private (use the public/private/protected keywords … ![]() |
The End.