1,358 Posted Topics
Re: [B]>>can someone code this in C++[/B] [URL="http://www.daniweb.com/forums/announcement8-2.html"]Yeah, you.[/URL] | |
Re: Variations of this question have been popping up with disturbingly high frequency the last couple weeks. Did you try searching the forums at all? To dynamically allocate a 2-D array, you need to declare the array pointer as a pointer-to-pointer (i.e. dataType **ppName), not simply a single pointer (i.e. dataType … | |
Re: The variable "name" is an array of std::string. As such, the actual variable called "name" is a pointer to std::string. Since it's a pointer to std::string, you can't input to it directly. You need to input to an element of the name array:[CODE]std::string array[10]; for (int i = 0; i … | |
Re: Here's a start:[CODE]#include <iostream> using std::cout; using std::cin; int main() { return 0; }[/CODE] Fill it in. You can start by getting the inputs from the user... | |
Re: Bubble Sort is dependent on performing multiple swaps to move values to their sorted locations. The idea is that if no swaps are performed, then logically everything must be in the proper location. If everything is in its proper location, the sort is finished whether all passes have been completed … | |
Re: A couple quick questions first: How many instances of "MyClass" do you intend to have in your final program? Other than the declaration, do you intend to use this vector anywhere else outside "MyClass"? This sounds like a candidate for a static member variable, but it depends on your answers. | |
Re: [QUOTE=txwooley;1377266]So the "% x" is required? I only know about rand() because of a tutorial I am reading. The author used rand() to create a numbers guessing game, but did not give it parameters. Thanks for the help guys.[/QUOTE] No. This statement: [iCODE]x = rand() % 1500 + 1;[/iCODE] is … | |
Re: Did I miss a question buried somewhere in that wall of unreadable code? [URL="http://www.daniweb.com/forums/announcement8-3.html"]In the future, please use [B][COLOR="Red"][noparse][CODE]..code blocks...[/CODE][/noparse][/COLOR][/B] when posting code.[/URL] Also, [URL="http://www.daniweb.com/forums/thread78223.html"]please be more clear about what your issue is[/URL]. There are very few of us that can divine it. | |
Re: Hmmm.... I don't know if I should respond to this. Something smells fishy here. | |
Re: Hmmm.... I don't know if I can help with this particular issue (kinda rusty). But you don't have to "send" it. [URL="http://www.daniweb.com/forums/announcement8-3.html"]Just post it here.[/URL] | |
Re: Function overloading is the process of writing multiple versions of the same function to operate differently based on the argument dataType(s) and/or argument count. Which version of the function gets called/executed depends on the arguments provided. A common example is an "area" function from geometry. You can overload area() to … | |
Re: Generally, an inline function is [B]requested[/B] when it's a short function (as in only 4 or 5 lines) and you don't want the additional execution overhead associated with a function call. This makes for quicker execution, but that's offset by a larger program because of all the extra code expansion. … | |
Re: Where exactly are you stuck? Does it have anything to do with this function:[CODE]int calCredit(int numChildren, double income) { int totCredit = 0; totCredit = numChildren * 1000; if (income < 70,000) { if (totCredit > 4000) { totCredit = 4000; } } return totCredit; }[/CODE] Because I can tell … | |
Re: We certainly can help, but I'm afraid [URL="http://www.daniweb.com/forums/thread78223.html"]you're going to have to do better than that[/URL] if you want any [B]useful[/B] help. We don't know anything about your situation or goals except that you are trying to implement an operator that works for char. [URL="http://www.daniweb.com/forums/announcement8-2.html"]Also, please don't expect us to … | |
Re: Do you have access to the definition of the itk::RescaleIntensityImageFilter template? Are you sure it takes 2 template arguments? EDIT: Oops, a little slow... Don't you hate it when you get sidetracked? | |
Re: [QUOTE=Leppie;1376908]Thanks David, I'll examine the links and try to proceed, one quick question, does the file need to be closed between inputting and outputting or can I do both operations to the file and just close it at the end? (If it's answered in the links then sorry for the … | |
Re: You'll have to post some relevant code. Without it we haven't a clue. It sounds like you attempted a declaration either that you didn't need to or incorrectly. The only way to know is to review the code. | |
Re: If I'm reading it correctly, it's using a recursion to perform the insert operation after it finds the sorted location of the first unsorted element. It takes the place of this part of the algorithm:[CODE] if (m_DataSet[unsorted] < m_DataSet[destination]) { //if the unsorted element should be before the destination element … | |
Re: [B]>>The build is successful but I have 2 errors while compiling here is my code[/B] Um, last I checked, if you have 2 errors while compiling, the build isn't successful... It might be useful if you shared those errors. Very few, if any, of us are psychics. We can't even … | |
Re: [QUOTE=SgtMe;]Firstly, you have you have this line wrong: [CODE]while (quantity >50);[/CODE] Surely it should be '<' instead? ...[/QUOTE] No, that loop is an input validation loop so the OP has the condition correct. The problem is they used a do-while loop, which isn't the correct type of loop. Since it's … | |
Re: When one class inherits from another, the object of the derived class has contained within it an object of the base class. In order for the inheritance to work with templates, you have to provide a template argument for the compiler to use when generating the base object. Thus the … | |
Re: According to your code, the variable "x" is an object of type "ItemType". Also, according to your code, "ItemType" is a typedef for the built-in "float" type. I think that pretty much explains why it's throwing errors when you try to call x.getLength(), x.comparedTo(), x.ComparedTo(). Also, notice the capitalization differences … | |
Re: Line 24 "updatedCost = cost" is an error because you are trying to store a "CostType" to a double pointer. How is "CostType" defined? This looks like an attempt at a template, but it's not implemented correctly. The error on Line 26 is the result of attempting to modify an … | |
Re: Well, it's a couple things: First, there is no version of the new operator that can create a 2-dimensional array directly. The operator new[] can only be used for 1-dimensional arrays. You must use the operator multiple times to produce a multi-dimensional array. Second, a 2-dimensional array uses 2-levels of … | |
Re: What you have done is correct. All those folders are is an organizational tool whose display is facilitated by an XML file called a "project file". If you look at your computer's actual file system, those folders don't exist. All 3 files are in a folder that is named after … | |
Re: For starters, please use proper written English, not TXT. [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]Have you read the member rules?[/URL] [QUOTE=Member Rules] Keep it Clear [LIST] [*]Do post in full-sentence English [*]Do wrap your programming code blocks within [noparse][code] ... [/code][/noparse] tags [*]Do use clear and relevant titles for new threads [*][B]Do not write in … | |
Re: [QUOTE]Examples include substituting the <X> header for the <X.h> \ header for C++ includes, or <iostream> instead of the deprecated header \ <iostream.h>.[/QUOTE] Um..... I think your compiler has said it all... Try actually reading it. The way you've written your code is not per the current C++ standards. There … | |
Re: When templatizing a class, you need to use a template statement before the class definition. Additionally, a matching template statement should preceed each function implementation that is not part of the class's definition. You only need the Template Parameter on the class name, not the function name. This:[CODE] Vector<T>::Vector<T>() :capacity(0), … | |
Re: That's normal. In the STL end() returns a pointer that is 1 past the last element in your container. If it returned a pointer to the actual last element, you would not be able to use it for traversal operations. This wouldn't work if that wasn't how it behaved:[CODE] std::list<int>::iterator … | |
Re: First, why is arr global? Does your assignment require it to be? You really should move arr to the local scope of main(). Second, your functions aren't defined properly. They are defined to work on a single element of the array, not the entire array. You will have to make … | |
Re: Actually, even though it really should be addressed, the warning itself isn't a serious problem. It certainly could be, that's why there's a warning generated, but the value is input a couple lines later. That variable is part of the problem though. It is declared as a pointer to char, … | |
![]() | Re: It is understood that you are asking about an issue in your *.h file and that there are no #includes above this class' definition. gerard is asking you about your *.cpp files. With an error like this, the cause of the problem frequently is not actually in the file that … |
Re: OOP is based on classes. This is usually a topic covered at the end of a book used for coursework. Here is a link to the first of several tutprial pages on cplusplus.com: Start on this page, then read the next 4 or 5 pages. [url]http://www.cplusplus.com/doc/tutorial/classes/[/url] | |
Re: More information would be helpful. What are you trying to accomplish? Are you trying to create a single-dimension array of pointers to something or a multi-dimensional array of pointers to something else (?[B]int[/B]s?, perhaps) ? I'm having a hard time telling from the context of your code... | |
Re: Where are your declarations of ROWS and COLUMNS? I don't see them. I would start by deciding how you're going to identify the Columns (x-coordinate) and Rows (y-coordinate) of player moves. I think you should consider getting from the user the column (x-coord) that they want to place a "chip" … | |
Re: For starters, why are firstanswer and secondanser global? They should be local to main(). Also, the global a and b are of no value to you and should not exist, get rid of them. Your loop is not built correctly. You have an infinite loop. What's wrong with this line:[CODE]while … | |
Re: [QUOTE=arshad115;1372090]worked fine on my pc. gave this output: X() Y() Z() f() press any key to continue. I am using Visual studio 2008,windows[/QUOTE] When Multiple inheritance isn't implemented properly, what happens is highly compiler specific. Users of VC++ are the lucky ones, it will APPEAR to work correctly. To implement … | |
Re: [QUOTE=Ancient Dragon;1372033]what compiler are you using? AFAIK all c++ files are named either *.cpp or *.cc, depending on the compiler. g++ on *nix normally use *.cc.[/QUOTE] This is the third thread I have seen on this same assignment, at least. [URL="http://www.daniweb.com/forums/thread321477.html"]"';' expected before class"[/URL] [URL="http://www.daniweb.com/forums/thread321452.html"]"Initializing specific objects"[/URL] The OPs classmates … | |
Re: It's a function that is supposed to return a pointer to a list_link. As defined though, it doesn't doesn't do anything useful. | |
Re: [URL="http://www.cplusplus.com/reference/iostream/"]Look up something called a stringstream, that will help alot.[/URL] | |
Re: [B]>>something is either running out of memory or looping too far and trying to access a part of the vector that dosnt exist[/B] That's exactly what it means. I haven't looked at the attached files yet, but I don't see anything in the code that you posted that should be … | |
Re: Once you encrypt the string, what are you supposed to do with it? Right now, I'm not exactly sure what you're doing, but it's not generating an encrypted string. | |
Re: Your code is organized a little strange so I'm having a hard time wading through this. It looks like the problem is that you are using local variables incorrectly and not storing anything to the appropriate member variables. I don't see any instance where you access [iCODE]this->mHead[/iCODE] or [iCODE]this->mTail[/iCODE]... | |
Re: [URL="http://www.daniweb.com/forums/announcement8-2.html"]Nice Copy/Paste job. Why don't you show us how to do this?[/URL] You must know something about writing a program. Start by writing a program that determines if a number is prime. Then, expand its capabilities. Here's a start:[CODE]#include <iostream> using std::cout; using std::cin; using std::endl; int main() { return … | |
Re: You don't need conio.h, there is almost never an occasion to use that [B]non-standard[/B] header. [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]Also, this isn't your thread, start your own.[/URL] | |
Re: [B]>>sorry that smiley is not supposed to be there![/B] Use the [noparse][noparse]...[/noparse][/noparse] tag to prevent things like that. Your error is that you are attempting to use "new" to create the objects stored in your Piece arrays. The return from new is a pointer to an object, not an actual … | |
Re: The issue is most-likely that "is_prime.cpp" is not getting compiled as part of your compilation process. What OS and IDE are you using? Is the file "is_prime.cpp" included as part of your "project" in your IDE? If not, it doesn't get compiled and the linker can't find the object code … | |
Re: If you only want to allocate pbuffer once, then yes, I think a std::string probably would be a good choice. It's essentially a vector of char which gives you access to many of those features and functionalities. Plus, it gives you the option to use stringstreams and other more-convenient operators/methods … | |
Re: Um... I think it will make your life much simpler if you make better use of loops. A prime example:[CODE]void getMonth(string months[])// Asks user for current month. { int month = 1; cout << "\nPlease enter the current month. " << "Use 1 for January, 2 for February, " << … | |
Re: [B]>>The methods you stated seem to be for arrays, but I am asking for multidimensional arrays. So, please try to stick to the area of concern..[/B] Once you figure out single-dimensional arrays, it is not a big leap to multi-dimensional, so it is "the area of concern". Each dimension of … |
The End.