1,358 Posted Topics
Re: Are you sure that's your current code? The code you posted does not compile. You have undeclared identifiers on Lines 39, 57, and 58. According to your previous post, it should compile. Seriously, read the formatting guidelines that WaltP gave you a link to. You code is almost impossible to … | |
Re: So do you want to put in, for example, "3 2" and have it find the second occurrence of the value "3"? | |
Re: Perhaps this thread will help. [url]http://www.daniweb.com/forums/thread311226.html[/url] | |
Re: A little word of advice: When posting code, replace your indentation tabs with spaces, or change your IDE's settings to do it for you. Otherwise, your code winds up looking really strange. Poorly formatted code is prone to errors and is hard to read. It seems that you are missing … | |
Re: Not unless you tell us something about the errors you are getting. Otherwise, all we can do is make wild guesses. The only thing that I see right off hand is that main() doesn't have a return statement, it's bad practice, but that's not a huge deal. EDIT: Just found … | |
Re: Must be a compiler-specific thing. When I run this on VC++ 2008 I get:[QUOTE=VC++ 2008 Console Output]class Security * class Metal[/QUOTE] | |
Re: [QUOTE=kuchick32;1369807]I'm trying to use a getline function in my program. I have the correct cout function but when I try and enter my input the program keeps wanting me to enter a couple of times and then that's what comes out. I'm very confused on what I'm doing wrong in … | |
Re: Because Y inherits from X. Due to the inheritance, when you have an object of Class Y, you also have an object of Class X that is embedded within the Y object. When you make a copy of the Y object, you are also making a copy of the embedded … | |
Re: The int data type is a numeric type that can only store whole numbers. You are trying to input and compare to characters. These types are not compatible. You must change "ticket" to the char data type. You will also have to "normalize" the input because 'a' and 'A' are … | |
Re: It appears your trying to create a 2-dimensional array. The problem is, a pointer for a 2-Dimensional array has 2-levels of indirection, but you are attempting to create a pointer with 3-levels of indirection. Try taking the [Square Braces] off your declaration of vecCamiao... | |
Re: Welcome. One piece of advice, [URL="http://www.daniweb.com/forums/thread78223.html"]make sure you word your questions very clearly,[/URL] we don't know what you're thinking and we can't see what your working on unless you tell/show us. On that note, I would certainly love to help you, but I don't understand your question. I think you … | |
Re: You need to re-initialize fact to 1 when the loop restarts. You are getting such an unusual answer because you haven't reset your program's state. You must always reset your program's state if you are implementing a "would you like to do again?" style loop in it. | |
Re: That sounds like a very worth while assignment. [URL="http://www.daniweb.com/forums/announcement8-2.html"]What have you accomplished so far?[/URL] Is there anything in particular that you had a question about? | |
Re: You need to "seed" the RNG. If you don't, it will generate the same series of "random" numbers every time. [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/srand/"]Look up the function srand().[/URL] | |
Re: I'm afraid we're going to need more information. It's not real clear what you're trying to accomplish. A nested for loop is nothing more than a for loop inside another statement block of some sort, such as another for loop.[CODE]for (int i = 0; i < limitingValue1; ++i) { //outer … | |
Re: I think you need to check the name of your FILE pointer. It seems to change from "arq" to "arch" then back to "arq"... | |
Re: When debugging, always start with the first error generated and fix that. Fixing that could potentially fix others. Conversely, it could also reveal others that weren't detectable at the time. There should be error messages that follow those error codes. Can you post the first couple error messages you are … | |
Re: When you use the stream injection operator ('<<') it automatically reads through the array and outputs characters until it reaches a NULL-terminator. The extraneous/garbage characters are any characters that exist between the last char of "your" string and the first NULL that it can find. Properly initializing and/or terminating comp1 … | |
Re: I can see a couple things here: 1. Have another look at Line 70:[CODE]Square*** tbl = new Square**[xMax];[/CODE] This declares a new tbl variable that is local to your board constructor and is destroyed when your constructor terminates. Because it has the same name as your private variable Board::tbl, it … | |
Re: The output function printf() is valid C++, it's just a function that's inherited from C. If you in fact want to do this in purely C++, you'll have to use [URL="http://www.cplusplus.com/reference/iostream/manipulators/"]manipulators[/URL]. | |
Re: Is this project supposed to be OOP? If so, do you know how to find and declare your classes? Have you done so? [URL="http://www.daniweb.com/forums/announcement8-2.html"]We aren't rent-a-coders, I think you need to show us some effort before we can help much more.[/URL] | |
Re: I would consider defining Pi as a global constant instead of using the "magic number" 3.1416. That way, you only have to define it once and you can't accidentally enter an incorrect value manually.[CODE]#include <iostream> #include <iomanip> #include <cmath> const double PI = 3.1416; using namespace std; int main () … | |
Re: Before I answer, I have a couple questions. What are the dimensions of the arrays? Are they dynamically allocated or static? Basically, you really need to post some more relevant code, there's not enough here to work with (for me anyway). | |
Re: [B]>>First off, Ancient, it surprises me that you've managed to get to 19,000 posts and your standing in here while still remaining such an ass. Amicability shouldn't be countered with such bitchiness. Please feel free to just completely ignore ANY of my posts you ever see.[/B] After a comment like … | |
Re: How big are the values we're talking about? [URL="http://www.cplusplus.com/doc/tutorial/variables/"]Many doubles can go out to something like +/- 1.7 E +/- 308.[/URL] You could try a long double, but many compilers implement them the same as a regular double. Without going to an external library specifically designed for extremely large (or … | |
Re: [URL="http://www.daniweb.com/forums/thread78223.html"]You really need to be more specific.[/URL] Making such generic statements makes it very difficult for us to help you. A linker error is returned when the implementation for a function you're calling can't be found. This typicallly happens because you either didn't include the proper object file in your … | |
Re: I thought you had to read from a file... Either way, that's not correct. You need to input to some input variable then store the value to max and min, not input directly to max or min:[CODE]inFile >> someVar; min = someVar; max = someVar; while (inFile >> someVar) { … | |
Re: I'm not sure exactly what to tell you about your 4 5 issue, but your second question is a pretty common one. What you are experiencing is called "stream corruption". It happens when the data type of the input is not compatible with the data type of the variable expecting … | |
Re: Do you know how an insertion operation works? What the assignment requires is that you verify there is sufficient space in the stack, then perform an insertion at element 0 rather than storing it to the first available legal space within the array. Something like this:[CODE] //assume the following variables: … | |
Re: It looks like Intrade has already covered it, but what you need/he suggested is called a "forward declaration". It's the same concept as a function prototype. | |
Re: [QUOTE=Johnny 5]Need input![/QUOTE] Yes, that's correct Johnny, we know nothing. :P @OP: Do you mind posting the code in question? | |
Re: @OP: The algorithm for insertion sort works by scanning through an array from 0 to (ARRAY_SIZE-1). As it does so it re-arranges the elements in the array so that the elements closer to Element 0 (the beginning) than the current position are "sorted" and those elements closer to the end … | |
This ad for "Parallels Desktop 6 for Mac": [url]http://i.proadsdirect.com/952912e30c5945a32933d9cfd9b773a2.swf*[/url] Needs to be reigned in. There is something in it that will not allow the site's menu-bar drop downs to display properly. It insists on being the top display layer and blocks access to the menu items. I have been forced … | |
Re: Generally a linker error is caused by calling a function that you don't have an implementation for. The linker throws and error saying "you've called this function, and I know it's supposed to exist, but I can't find it." I don't get involved in Win32 programs, but I do know … | |
Re: What you are trying to create is called a function. [URL="http://www.cplusplus.com/doc/tutorial/functions/"] Here is some information.[/URL] | |
I am trying to sort a vector that is a [B]protected[/B] member of a templated class into a Descending order based on the [I]second[/I] member of the contained std::pair objects. The vector has the following declaration:[CODE]vector< pair <const T, int> > mode; //holds pairs to define the mode(s) of the … | |
Re: You're going to have to post some code so that we can see what you are doing. Otherwise, all we can do is take a shot in the dark. | |
Re: You can't initialize values inside a class' definition. You have to do it within the class' constructor(s). For a vector, you would simply declare the vector, then in the constructor you would call either vector::resize or vector::reserve. Which you use depends on how you plan to use the vector later. … | |
Re: [QUOTE=rashid85;1359390]Dear gerard4143, Yes it is a home work for my sister. and I'm trying to help her with the right code. Thank you.[/QUOTE] Make her do her own homework. How does either of you expect to learn if you don't even try to do it? | |
Re: Try taking out the "splats"... [CODE]template <typename T> void showMatrix(T someMatrix);[/CODE] With them, you are effectively creating a pointer with 4-levels of indirection. A 2-d array (matrix) only has 2-levels of indirection and those should come over to the template with the array/matrix. | |
Re: [QUOTE=LevyDee;1358623]DOH! wow guys, I apologize to who ever looked at this thread. Dont judge me =([/QUOTE] just remember, you can create instances of the std::string class without the header. But, in order to do anything with them, you need it because that's where all the functions/operators are defined. | |
Re: You will get a similar effect with any numeric value that is uninitialized. What the reported value represented is depends on the data type. The thing you need to remember is that this isn't actually a valid value. You didn't specify exactly which compiler you're using, but you alluded to … | |
Re: Does the assignment tell you to use 2-arrays? Using an array to store every letter in the file is a little difficult to do unless you know how many letters there are to begin with. You don't have to store them to output them. You can just use a temp, … | |
Re: I notice that you are using a lot of "magic numbers" for your array sizes, set sizes, etc... If you are familiar with constants, you may want to consider adding a few to minimize your chances of having issues. This:[CODE]const int SET_SIZE = 15; const int RAND_RANGE = 10; int … | |
Re: [QUOTE=Unimportant;1357709][CODE] switch( var ) { case 1: // ; break; default: std::cout << "Default." << std::endl; break; } [/CODE] Any case except the integer 1 will output "Default.", as it is the default statement. I cannot think of a different context for this question, if it's something else you'll need … | |
Re: [URL="http://www.cplusplus.com/reference/std/typeinfo/type_info/"]There is information about a data type known as type_info here.[/URL] If you do something like this:[CODE]#include <iostream> #include <typeinfo> using namespace std; int intFunc(); int main () { cout << "Type of intFunc is: " << typeid(intFunc).name(); return 0; }[/CODE] You will get this:[QUOTE]Type of intFunc is: int __cdecl(void)[/QUOTE] … | |
Re: Start by finding the center of the matrix, then expand your algorithm from there. If you have an N x N matrix, where is the center? | |
I have a couple of template classes "Stats<T>" and "Numerical<T>" within a "Statistics" namespace. The Numerical<T> class inherits publicly from Stats<T>. They are defined as below.[CODE] namespace Statistics { //declare Statistics namespace template <typename T> class Stats { protected: vector<T> dataSet; //contains the actual data set to be analyzed /* … | |
Re: Looks like you have the basic idea, real_escape_string() is good for preventing SQL injection because it escapes special characters. It helps to screen out malicious input from a user. If you want to be sure the actual format of the input is acceptable for the field or database element it … | |
Re: A "String Literal" is a null-terminated array of char (a C-Style string), it is not a C++-Style string object. This is an important distinction when declaring C++ std::string objects because there are several different overloads of the std::string constructor: The declaration of s0 calls [iCODE]string ( const char * s … |
The End.