1,358 Posted Topics

Member Avatar for leaposto

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 …

Member Avatar for Fbody
0
128
Member Avatar for cogitoergosum18

[URL="http://www.cplusplus.com/doc/tutorial/"]Here's an online tutorial and reference, see if that helps.[/URL]

Member Avatar for Takeshi91k
0
211
Member Avatar for franchico

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.

Member Avatar for franchico
0
5K
Member Avatar for qtl

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 …

Member Avatar for qtl
0
158
Member Avatar for aikiart

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.

Member Avatar for Fbody
0
159
Member Avatar for vijaybrar

[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 …

Member Avatar for Fbody
0
158
Member Avatar for super-duper

First, your code is nearly impossible to read, in the future the CODE button when posting code, then we can help easier.

Member Avatar for Fbody
0
414
Member Avatar for adman_2005

[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 …

Member Avatar for jordan00191
0
419
Member Avatar for aikiart

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.

Member Avatar for aikiart
0
113
Member Avatar for shubhankarmayan

[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.

Member Avatar for prvnkmr449
0
434
Member Avatar for nizbit

[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.

Member Avatar for dusktreader
0
538
Member Avatar for great_learner

Is there anything else drawn over top of them? They may be there, just hidden by an errant draw order...

Member Avatar for Ancient Dragon
0
95
Member Avatar for arshiyafatima

[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]

Member Avatar for markiss_salado
-1
215
Member Avatar for chilambu

Operator overloading is much like function overloading. However, it is not possible to give specific advice as your post is rather cryptic.

Member Avatar for Duki
-1
114
Member Avatar for Babaty

[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 …

Member Avatar for Fbody
-2
88
Member Avatar for onako

I think the typeid operator and typeinfo header will be of interest to you. EDIT: Oops, too slow...

Member Avatar for LordNemrod
0
113
Member Avatar for alex k

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 …

Member Avatar for manojwali
0
121
Member Avatar for johnsign11

[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 …

Member Avatar for manojwali
0
157
Member Avatar for jelinky

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 …

Member Avatar for VernonDozier
0
190
Member Avatar for cnmsg007

[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]?

Member Avatar for manojwali
-1
79
Member Avatar for xLeonex

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]

Member Avatar for XMasterrrr
0
485
Member Avatar for xLeonex

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 …

Member Avatar for xLeonex
0
118
Member Avatar for koolman123

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>.

Member Avatar for mrnutty
0
101
Member Avatar for Jamesbch

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(); …

Member Avatar for Fbody
0
122
Member Avatar for Lord_Migit

You'll have to show us your output statement(s). It's likely that you are not de-referencing the pointer(s) properly...

Member Avatar for Lord_Migit
0
136
Member Avatar for lytnus

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, …

Member Avatar for lytnus
0
292
Member Avatar for udtohan_noriel

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.

Member Avatar for Duki
0
318
Member Avatar for mrrko

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]

Member Avatar for Fbody
0
752
Member Avatar for myk45

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 …

Member Avatar for Fbody
0
173
Member Avatar for ceeandcee

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. …

Member Avatar for Fbody
0
85
Member Avatar for walter clark

[URL="http://www.daniweb.com/forums/thread307189.html"]Here's a thread with a similar question[/URL]. Perhaps the link(s) there will help?

Member Avatar for Ancient Dragon
0
107
Member Avatar for myd5258

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 …

Member Avatar for Lerner
0
428
Member Avatar for fizzix66

[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 …

Member Avatar for Duki
0
144
Member Avatar for mommabear

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 …

Member Avatar for mommabear
0
108
Member Avatar for Empireryan

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 …

Member Avatar for Fbody
0
531
Member Avatar for grahf23

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 …

Member Avatar for grahf23
0
157
Member Avatar for tennis

[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; …

Member Avatar for Duki
0
93
Member Avatar for PixelExchange
Member Avatar for PixelExchange
0
119
Member Avatar for dorien

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 …

Member Avatar for dorien
0
4K
Member Avatar for helpme87

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].

Member Avatar for mrnutty
0
149
Member Avatar for Freespider

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 …

Member Avatar for Fbody
0
1K
Member Avatar for newbie_to_cpp

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 …

Member Avatar for ceriamultimedia
0
102
Member Avatar for Stefano Mtangoo

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 …

Member Avatar for Stefano Mtangoo
0
130
Member Avatar for harris21

[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, …

Member Avatar for mrnutty
0
300
Member Avatar for totalwar235

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? …

Member Avatar for totalwar235
0
110
Member Avatar for Jackk123

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 …

Member Avatar for Jackk123
0
147
Member Avatar for newbie_to_cpp

Use a loop, your code already has at least one in it, so you must be at least familiar with them.

Member Avatar for newbie_to_cpp
0
125
Member Avatar for shashwat gupta

[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.

Member Avatar for Fbody
-2
30
Member Avatar for aikiart

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 …

Member Avatar for aikiart
0
108
Member Avatar for mdl731

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...

Member Avatar for mdl731
0
130

The End.