1,426 Posted Topics
Re: according to this http://www.boost.org/doc/libs/1_36_0/libs/dynamic_bitset/dynamic_bitset.html You ahould be able to output direclty to your filestream using the << operator. They also have the >> operator set to get a bitset from the stream. | |
Re: a `char*` is considered a c-style string. It is just an array of characters. A `char **` is and array of `char*` which is to say it is an group of c-style strings. The string type is an ogject created from the class string. These are two different things. This … | |
Re: Just make the void RepMatrix funtion a provate function of the class. That way no one can use except you. | |
Re: • If all of the elements are in order and the entire array is full wouldn’t you just look at the index of id number - 101? | |
Re: You want to write your own copy constructor for any class that contains pointers. The reason for this is that the default one the compiler makes only performs a shallow copy. This means that the copy will be exactly the same as the original. With pointers this is bad because … | |
Re: Your multiplier array and your code to populate it is the problem. The array is of type int but you are trying to store a double into it. This will just cause a truncation problem for storing the values. The main issue is in your for loop on line 61. … | |
Re: I did a google search and it looks like this happenes when either or both g++ and gdb are not installed | |
Re: The problem you are having is that you are using an unsigned integer type. When you underflow that type it wraps around to the largest number it can be. You have to be very careful when you get towards the min or max number that your type can hold because … | |
Re: the string type is part of the standard namespace. if you are going to use types from the std namespace in a header file than you will either need to fully qualify the name like `std::string` or you could use a using directive like `using std::string;`. I would not use … | |
Re: You are calling delete on number in your destructor for your palindorme class. You shouldnt do that. All members of the base class should be taken care of in the base class destructor like you have on line 13. | |
Re: It all depends on how you code your program. If you have mechanisms in place in your code to handle error than you could try recover from that error. If that is not possible, than you could end the program gracefully and tell the OS that the program did not … | |
Re: if you are having a problem with file IO give this page a shot. http://www.cplusplus.com/reference/iostream/ifstream/ | |
Re: My suggestion is pretty much the same as Schol-R-LEA's. I would you a sieve of Eratosthenes to generate all number between 2 and the upper limit for your test. After that I would check and see if the number inputted is in the list. If it is then divide the … | |
![]() | Re: What error are you getting? To try and make finding the problem easier you should try to skim the code down to the smallest thing you can get that still produces the error. Try to fix that and then implement the fix into the larger code that you have. Seeing … ![]() |
Re: It will if you do not have the string header in your struct header file. Please post what you have. Its hard to see your screen from here. | |
Re: I believe the problem lies in the fact that you only have 1 paramater in your function. From functions I have seen you need to have at least one paramater that does not have a default paramater | |
Re: you should be initializing it your constructor | |
Re: what do you have right now? | |
Re: are you using the string class or are you using a char array? | |
Re: Well if you want to parse a string the best way i can think of is to you a stringstream. You get the input from the user using getline like you have and then you would put the string into the stringstream. After that you would output all of the … | |
Re: What happenes if you set pixels to null in your constructor? Pixels = NULL; | |
Re: Do you know how to use cin and cout? Have you heard of get() and/or getline()? Using those you can take anything in from the user you want in almost any way you want it. Generally what you should do is read in the entire line and then parse out … | |
Re: The reason you are having an issue is you are setting youngest equal to 0 before you start the for loop and as long as you have valid data you shouldnt have an employee with a zero age. // change youngest = 0; // to youngest = recordlist[0].age The condition … | |
Re: To continue Tumlee's point if you want the data to be in an unbeadable form than you are going to need to learn how to create a data structure and then write the structure to file in binary. One cavet of this is that text is still text in binary. | |
Re: Since you are dealing with the string class what happenes if you change it from 1 and 0 to '1' and '0' s += '1' s += '0' | |
Re: So you have a file that is 100MB large and you want to search it for a specific string? how are you storing yor string in your function? do you store a new string for each line in the file or are you putting the entire file into one string? … | |
Re: What happens if you change your for loop to for(markit = mark.begin(), courseit = course.begin(); markit < mark.end(), courseit < course.end(); ++markit, ++courseit) I think the problem you are having is that you are trying to use iterators from temporary objects but I could be wrong. | |
Re: The problem you are having is ring is declared as an int but you are trying to use it as an int array. | |
Re: All clear does in this is remove any error flags that might be present in the stringstream object. If you want to empty the stringstream then you want to use the ignore() function. Try replacing [icode]ss.clear()[/icode] on line 59 with [icode]ss.ignore(std::numeric_limits<streamsize>::max());[/icode]. You will need to include the <limits> header for … | |
Re: Ever think about just including the cctype header in your project? If you dont want to do that then what you have looks good as long as CCTYPE is defined in the cctype header file. If you want to check if something is not defined then you would use [icode]#IFNDEF … | |
Re: You do not need a while loop in your function. Think about the steps you need to do to get a factorial. There should be a conditional statment in a secursive function to check if you have reached a base case. There should be a call to the function itself … | |
Re: You need to use srand() to seed rand before you use it. For a game like yours i would use [icode] srand((unsigned)time(0)); [/icode]. You will need to use [icode] #include <ctime> [/icode] in your code to do this. | |
Re: You cant compare char strings like that. You have to use the strcmp() function. I you want to compare strings with the logical comparison operator than you could use the string class available from <string> or you have to write your own. | |
Re: Yes you can Overide any operator you want. This can be done globally or at a specific level. | |
Re: After line 16 add [icode]cin.ignore();[/icode]. This is beacuse you are mixing inputs and this will clear the '/n' that is left in the buffer after the call to cin with [icode]>>[/icode]. Not 100% sure how [icode]gets()[/icode] works but this fixes the problem when trying to use [icode]getline()[/icode] | |
Re: Well you can use a counter variable and every time you read a string increment the counter by 1. | |
Re: The problem with you logic is that i is starting out at 0 not 1. Since 0 is a number you have 0, 1, 2, 3, ... 98, 99. The reason i is 100 is because when i is 99 it get incremented to 100 and then it is checked … | |
Re: One of the problems with palindromes is the formatting. In this case you have commas and when you reverse the string they will not line up right but the letters in the sentence is still a palindrome. One solution would be to strip all punctuation and spaces from the sentence … | |
Re: I belive you need to increment j after line 27 and before line 28. Otherwise you are always starting back at the same place. | |
Re: So what you need is more like prime factorization. There are many threads on this site that talk about that. | |
Re: Well for starters an int can not hold decimals. A float or a double is required for that. you can do this with int's if you know how to use the % operator. | |
Re: to declare variables in c++ you do it as [code=c++] int x, y; [/code] So with that to declare a structure with an x and y variable you would do [code=c++] struct Point { int x, y; } [/code] Finally if you want to constuct you struct with values when … | |
Re: I didn't see a matching closing brace from then opening brace on line 147 | |
Re: Well I'm not looking at all of this code that's what using a debugger is for but at first glance line 47 is wrong. You are returning an object that doesn't exist. What are you using to compile your code? If you are using an IDE they normally have built … | |
Re: Well according to [URL="http://msdn.microsoft.com/en-us/library/5x4fwzb4.aspx"]this[/URL] the buffer needs to be 9 bytes long. Try changing [icode]datenew[8][/icode] to [icode]datenew[9][/icode]. | |
Re: if you want to get a whole of text uasing cin you need to use [URL="http://www.cplusplus.com/reference/iostream/istream/getline/"]getline()[/URL] | |
Re: Recursion is a function calling itself. [URL="http://www.daniweb.com/software-development/cpp/threads/401354/1718446#post1718446"]This[/URL] will show you recursion. If you look above that post you will se an iterative version of the same code. | |
Re: A linked list can only contain elements of the same type. You could make a list of list like [code=c++] std::list< std::list< int > >; [/code] |
The End.