1,358 Posted Topics
Re: Test code should use every part of the object. You should have data that produces a predictable result, then check the generated results against what you expected them to be. If they match, you know it handles that set of data correctly and you have an increased level of confidence … | |
Re: [URL="http://www.cplusplus.com/doc/tutorial/"]Here's an online tutorial and reference, see if that helps.[/URL] | |
Re: I suspect the format of the RegEx is not correct, but it's been so long since I've worked with them I can't be sure. AD is usually on about now, I'm sure he'll be along with a solution soon. | |
Re: I think you may be messing with undefined behavior with your initializers in your 1-argument version of your constructor. Both of these constructors should have similar construction: [CODE] xVec(int a):n(a),v(new double[n]){} //potential undefined behavior!! xVec(int a, double c){ n=a; v=new double[n]; for(int i=0; i<n; ++i) v[i]=c; }[/CODE] It's generally not … | |
Re: Your code has no doubt been through several iterations by now. You'll have to post your current error(s) and the relevant section(s) of the current code. | |
Re: [QUOTE=vijaybrar;1327846]the randomNumber is undeclared it says it don't run[/QUOTE] It doesn't work because of this: [CODE]if(guessed) //if they guessed the number need a new one { srand(time(0)); int randomNumber = rand() % 10+1; guessed = false; //reset flag as new number now }[/CODE] randomNumber is declared inside the statement block … | |
Re: First, your code is nearly impossible to read, in the future the CODE button when posting code, then we can help easier. | |
Re: [QUOTE=adman_2005;1203130]I do not have a running program at this time, just a basic idea that I included in the question. i was hoping somebody could give me some suggestions or example on how to complete the items included in the problem statement i was given that build in the piece … | |
Re: It's really not possible within a single class because of how overloading works. But, as Duki suggested, you can probably do it with inheritance. | |
Re: [URL="http://www.daniweb.com/forums/announcement8-2.html"]And what have you tried so far?[/URL] This should be a simple matter of nesting 2 for loops. | |
Re: [QUOTE=firstPerson;1327009]Its probably because the professor wants the student to learn, instead of blindly using a function.[/QUOTE] Agreed, it is far better to learn proper techniques and algorithms than to learn to call some anonymous function someone else wrote. | |
Re: Is there anything else drawn over top of them? They may be there, just hidden by an errant draw order... | |
Re: [QUOTE=arshiyafatima;1326595]i have a project which involves swith case[/QUOTE] That's nice, so do I. [URL="http://www.daniweb.com/forums/thread78223.html"]What does yours do?[/URL] [URL="http://www.cplusplus.com/doc/tutorial/control/"]Do you need to know how one works?[/URL] | |
Re: Operator overloading is much like function overloading. However, it is not possible to give specific advice as your post is rather cryptic. | |
Re: [QUOTE=Babaty;1324104]Guys can u check this one out ? Q1: design a system that will read students information, display them in a table form, and implement some operation on them. The system must show the following: ========================================================================= Do you want to add new students? Do you want to display the student … | |
Re: I think the typeid operator and typeinfo header will be of interest to you. EDIT: Oops, too slow... | |
Re: Is N a pre-determined value, or is it an unknown value that requires a sentinel value to terminate the input loop? If it's a pre-determined value, write a for loop that runs from 0 to (N-1) then use the RNG to create the ages. If it's an unknown, a while … | |
Re: [QUOTE=elsiekins;1321409]first of all read this [url]http://www.cplusplus.com/reference/stl/vector/[/url] shows you how to use a vector. A vector is basically a dynamic array in which means you do not need to define the size before compiling it is done automatically[/QUOTE] Be careful how you say that. The resizing is only done under certain … | |
Re: Have another look at this part of VernonDozier's post [QUOTE=VernonDozier][CODE]const int NUM_QUESTIONS = 10; string key; string grades; int scores[NUM_QUESTIONS + 1]; int results;[/CODE][/QUOTE] You'll want something similar to Line 4. You will then have to create some code to manipulate the array. Think of each element of the array … | |
Re: [QUOTE][CODE]N_showdata.N_enterData()[/CODE][/QUOTE] Does this line look right to you (appx Line 6 of main()) when compared to this? [QUOTE][CODE]void N_enterData(char N_ID, char N_Name);[/CODE][/QUOTE] Oh, and where are your [URL="http://www.daniweb.com/forums/announcement8-3.html"][B][COLOR="red"][noparse][CODE]...code tags...[/CODE][/noparse][/COLOR][/B][/URL]? | |
Re: When you use the standard input streams, the extraction operator (operator>>) ignores whitespace, that's why you can't extract the space character. [URL="http://www.cplusplus.com/reference/iostream/istream/get/"]Try using the member function istream::get().[/URL] | |
Re: Your conditional formatting is not correct. You can not string multiple relational statements together in the standard algebraic format (i.e. x>y>z). You must create individual relations and connect them using either a logical AND '&&' or a logical OR '||'. [CODE] //use of logical AND if (x>y && y>z) //use … | |
Re: This reeks of a homework assignment. [URL="http://www.daniweb.com/forums/announcement8-2.html"]What have you done so far?[/URL] If it's not, look into the getline() function and the header <fstream>. | |
Re: In order to do that you need to use the scope resolution operator which is '[B]::[/B]' Observe: [CODE] #include <iostream> using namespace std; class Alpha; //forward declaration of class Alpha class Bravo { //begin declaration of class Bravo private: Alpha* m_pAnAlphaObj; //a pointer to Alpha public: Bravo(); //default constructor ~Bravo(); … | |
Re: You'll have to show us your output statement(s). It's likely that you are not de-referencing the pointer(s) properly... | |
Re: It sounds like you're looking to expand the [URL="http://www.cplusplus.com/doc/tutorial/polymorphism/"]polymorphic behavior[/URL] you have already created. Pay specific attention to the concept of a "Pure Virtual" function. Your second option is probably closest to what you'll want. But instead, change the name of BetterBase::AddBetterValues() to BetterBase::AddValues() and make Base::AddValues() a virtual function, … | |
Re: Start by building a while loop that counts up to the entered number. Once you figure that part out, [URL="http://www.daniweb.com/forums/announcement8-2.html"][B]and post your effort[/B][/URL], we'll be able to help you more. | |
Re: You need Java help, post in the Java forum and don't hijack dead threads. [URL="http://www.daniweb.com/forums/announcement8-2.html"]I don't think you'll get much better help there though.[/URL] | |
Re: The C++ Standard headers are a collection of named functionalities, not merely a collection of names, that all C++ compilers are required to provide at a minimum. I believe they are permitted to either be implemented as header files or implemented directly within the compiler itself, as long as it … | |
Re: It's been a while since I worked with PHP, but I'm sure you can just put the variable directly in the braces. echo $sum[$wk]; If you need the rest of the string that you have entered, change the single-quotes to double-quotes. PHP will resolve a variable that's contained within double-quotes. … | |
Re: [URL="http://www.daniweb.com/forums/thread307189.html"]Here's a thread with a similar question[/URL]. Perhaps the link(s) there will help? | |
Re: You'll want to pass your deal method a reference to your player array as an argument as well as a reference to the deck array. Then you'll transfer the card pointer from the deck array to the player's hand array. A program like this would usually be part of an … | |
Re: [QUOTE=fizzix66;1321867] basePtr->nVirt(); //???? /* why does a pointer of base type still call base methods when it is pointing to the address of a derived obj? do base obj pointers always point to base methods even when pointing to derived obj's? */[/QUOTE] Because even though it's a derived object, there … | |
Re: It just looks like it's getting skipped. There is a dangling newline on the input stream that is getting consumed by the input statement for the last name. To remove it so that your next input behaves properly you need to use a [URL="http://www.cplusplus.com/reference/iostream/istream/ignore/"]cin.ignore()[/URL] immediately after your input statement for … | |
Re: Do you actually have to log the guesses or simply count the number of guesses and log the guess counts? If you only have to count them (which your post seems to indicate), just use a counter variable and increment it each time the user enters a guess. Then, when … | |
Re: You have an extraneous close brace on Line 57. EDIT: Nvm, it now appears to not be the case. [URL="http://www.gidnetwork.com/b-38.html"]You should work on your code formatting a little.[/URL] Not sure if it's just the way the page is wrapping your code or your formatting. On this site, a "space" or … | |
Re: [QUOTE="Duki"]Someone should probably check my answer on this part though...[/QUOTE] I think you have your funcionality backward. Using this code: [CODE]#include <cstdlib> #include <ctime> #include <iostream> #include <vector> using namespace std; typedef vector<int>::const_iterator constIntIter; typedef vector<int>::iterator intIter; int main() { const int NUM_COUNT = 10; const int NUM_RANGE = 101; … | |
Re: Do you experience this on a different computer as well, or just your own? | |
Re: How exactly were you reading the converter that you linked? I think you may have read it incorrectly. The digits in hexadecimal are 0-9 and A-F with A-F representing the decimal values 10-15 resp. There is no single digit that represents 16 in hex. If you convert decimal 16 to … | |
Re: I suggest you read about [URL="http://www.cplusplus.com/reference/stl/map/insert/"]the map<>::insert() member function[/URL] and [URL="http://www.cplusplus.com/reference/std/utility/pair/"]the pair<> struct[/URL]. | |
Re: That header file looks okay. There may be an include you need, but I don't see anything that should need one. The error must be in another file in your solution/project. Is this file #included after another file that could perhaps have an error in it? This is generally the … | |
Re: Narue's functions? I don't see where she posted in this thread. Or are you referring to [URL="http://www.daniweb.com/forums/thread90228.html"]this thread[/URL]? If so, that method is an advanced method of manipulating the input stream to be sure that it is always clean. It makes heavy use of the member function [URL="http://www.cplusplus.com/reference/iostream/istream/ignore/"]istream::ignore()[/URL] to remove … | |
Re: Those functions are specializations. Why not just put them in the child objects? That way you don't have to worry about how to avoid implementing them for the classes you don't want to have them. It's a basic principle of the inheritance mechanism. They don't have to exist in the … | |
Re: [QUOTE=ganesh_IT;1317349]Hi harris, yes we can call constructor explicitly, but we cant call destructor.] [CODE] class sample { public: explicit sample() { cout << "Constructor called" << endl; } ~sample() {} }; int main() { sample obj(); //explict call only here allow because of explicit keywoed } [/CODE][/QUOTE] That doesn't work, … | |
Re: Your post is rather confusing, you'll have to answer these if you want any help: What exactly do you think is the problem? Note: I saw your comment indicating you think it's in C_Name(), but you'll have to elaborate. Does it compile? If not, what does the compiler tell you? … | |
![]() | Re: Your code should work, but I see some ways to improve it. You haven't given the stream an output mode, but it should be okay, it'll default to ios::out|ios::trunc. Your for loop will work, but in this situation you're better off using a less-than instead of a not-equal. Q. What … ![]() |
Re: Use a loop, your code already has at least one in it, so you must be at least familiar with them. | |
Re: [QUOTE=shashwat gupta;1317709]want to print 1 4 2 3 3 2 4 1[/QUOTE] [URL="http://www.daniweb.com/forums/announcement8-2.html"]LOL![/URL] Obviously you didn't read the forum rules. Not only is this a thread rez hijack, it's a "givemethecodez". [URL="http://www.cplusplus.com/doc/tutorial/"]Start studying[/URL] and good luck with your assignment. | |
Re: In recursion, you get several copies of a function all running at the same time with each subsequent copy running inside the previous one. Once the end condition is met, the inner-most copy of the function returns causing the rest of the copies to return and send their information back … | |
Re: What does it tell you when it crashes? I don't see a return statement in your main(), but I wouldn't expect a crash because of it... |
The End.