Search Results

Showing results 1 to 40 of 1000
Search took 0.09 seconds.
Search: Posts Made By: Lerner
Forum: C++ 9 Days Ago
Replies: 5
Views: 178
Posted By Lerner
I'd write a function called WriteTreeToFile, or something similarly obvious. I would pass the root of the tree I want to write to file to the function. In the function body I would basically write...
Forum: C++ 9 Days Ago
Replies: 3
Views: 129
Posted By Lerner
getline(temp, ',');
willl take Hello from the string Hello, World and put it in temp, if temp is declared to be an STL string object.
Forum: C++ 9 Days Ago
Replies: 3
Views: 129
Posted By Lerner
In the example shown I'd probably use the appropriate version of getline() for the type of string I'm going to use with the comma char as the delimiting char. This could be generalized to using any...
Forum: C++ 9 Days Ago
Replies: 5
Views: 178
Posted By Lerner
Not a traversal function. You want to be able to traverse without needing to write to file each time you do a traverse.

A separate save function is probably best. That gives you more control. ...
Forum: C++ 11 Days Ago
Replies: 1
Views: 108
Posted By Lerner
You use the STL string class later in your program so why not use it here, too:
string Dictionary[12][2] ={ {"God", "osalobua"}, etc
and here:
string word;

Line 35 could then be:
for(i = 0; i...
Forum: C++ 11 Days Ago
Replies: 5
Views: 147
Posted By Lerner
purposely over commented code for beginner to understand process
//declare a flag variable
bool invalidInput;

//outer loop controls number of digits input
while(k < MAX_DIGITS)
{
//reset...
Forum: C++ 11 Days Ago
Replies: 3
Views: 199
Posted By Lerner
Do you know how many items or a maximum number of items there are in the file? If not an array probably isn't the best container to hold the data, unless that it is the container type you are...
Forum: C++ 15 Days Ago
Replies: 5
Views: 162
Posted By Lerner
Try another example so we can understand better what you are trying to do.

This:
cout << 4 + 7;
works fine as does this:
string word1 = "hello";
string word2 = " world";
cout << word1 +...
Forum: C++ 15 Days Ago
Replies: 5
Views: 162
Posted By Lerner
"Content-length: "
That is a string and this:
BUFFER.length()
equates to an int. So when you use the + operator between the two are you trying to concatenate an int onto the string or are you...
Forum: C++ 15 Days Ago
Replies: 5
Views: 264
Posted By Lerner
Notice the different placements of the curly brackets betweenn the code written by Clinton Portis and your code. He checks the value of counter within the while loop to start a new line if needed,...
Forum: C++ 15 Days Ago
Replies: 2
Views: 147
Posted By Lerner
Pointers are useful for a variety of reasons. For, example, let's say I want to pass the value of my salary from one function to another. The value of my salary will be changed in the function it is...
Forum: C++ 20 Days Ago
Replies: 5
Views: 219
Posted By Lerner
Be more descriptive of the problem and you are more likely to get an answer. Not everyone is going to download, compile, run, analyze and then post a response.

After quickly reading through...
Forum: C++ 20 Days Ago
Replies: 4
Views: 208
Posted By Lerner
No need for AssignValue to be a friend function unless it is a requirement of the assignment.

How will AssignValue know how many digits to place before and after the decimal point? 123.456 ...
Forum: C++ 20 Days Ago
Replies: 4
Solved: Encryption
Views: 202
Posted By Lerner
If you know the first key then maybe something like this will work.

Encrypt:
while there are letters to encrypt
generate random letters until current key is generated
place a letter of message...
Forum: C++ 25 Days Ago
Replies: 3
Views: 232
Posted By Lerner
First, I'm surprised the code compiles given that you declare StoArrayXYZ using a non-const int.

You should probably have the class methods defined in a file of the same name as the header file...
Forum: C++ 26 Days Ago
Replies: 5
Views: 157
Posted By Lerner
Each function call in the recursive approach decreases inum by 1 until inum is zero. When inum is zero the function stops calling itself. That same control can be written into the control...
Forum: C++ 26 Days Ago
Replies: 3
Views: 254
Posted By Lerner
If you want lines 45-48 to run only in association with the last else if, then they should be enclosed in a code block using curly brackets. Probably a better thing, however, would be to output...
Forum: C++ 26 Days Ago
Replies: 5
Views: 157
Posted By Lerner
Where do you give num and num1 a value before you pass it to either the recursive or the iterative process? Shouldn't line 22 and 23 be between line 28 and 29?

Expand line 46 to three lines:...
Forum: C++ 26 Days Ago
Replies: 3
Views: 233
Posted By Lerner
Focus your code posting to just the pertinent part. sometimes it's hard to know where that is, but in your case it shouldn't be.

Sounds like a do/while loop using something like isdigit() might...
Forum: C++ 26 Days Ago
Replies: 5
Views: 204
Posted By Lerner
To my knowledge you can't initialize just a portion of the elements in an array, it's all or none. You can use a loop to assign a desired value to a portion of an array. That's what I would...
Forum: C++ 26 Days Ago
Replies: 2
Views: 169
Posted By Lerner
Please learn how to use code tags when posting code to this board. It is a bit of a hassle, but given it preserves the spacing you (should be) use in writing the code it is well worth it. There are...
Forum: C++ 27 Days Ago
Replies: 5
Views: 478
Posted By Lerner
Any list could be used as a representtion for a polynomial. If you are allowed to use the STL list class, go for it. If you have to write your own code for a list then you could do it C style...
Forum: C++ 27 Days Ago
Replies: 2
Views: 233
Posted By Lerner
Don't use postfix both hold the expression and act as a stack to evaluate the expression. I would suggest declaring an array of type double called myStack to use in evaluating the expression.
...
Forum: C++ 28 Days Ago
Replies: 5
Views: 478
Posted By Lerner
1) Use an fstream in in mode or a dedicated input stream called and ifstream.
2) A given linked list represents a given polynomial. Each node in the linked list represents a term of the polynomial...
Forum: C++ 28 Days Ago
Replies: 1
Views: 173
Posted By Lerner
In this specific case you could use two loops. One to get the number of elements indicated by length %2 and the other to however many groups of length/2 elements there are.
Forum: C++ 29 Days Ago
Replies: 6
Views: 260
Posted By Lerner
How about including public functions read() and write(). Both should take an int parameter. Then you can call MyObject.read(n) and MyObject.write(n). I don't see how you can overload [] to both...
Forum: C++ 29 Days Ago
Replies: 1
Views: 172
Posted By Lerner
Either:
1) change line 49 to: std::vector<GameObject*> myGameObjects; if you want an array of pointers to GameObjects so you can use newGO as declared on line 50.
OR
2) add a public mutator...
Forum: C++ 29 Days Ago
Replies: 6
Views: 260
Posted By Lerner
have you tried syntax similar to this:

MyObject.bvec[n];

It should work as long as n is less than the size of bvec, which in the code provided would anything 0-9 inclusive.
Forum: C++ 32 Days Ago
Replies: 1
Views: 113
Posted By Lerner
If you've ever been to an old fashioned library you know that they have the books all filed on shelfs according to some plan. If you just walk into the library and start looking for the actual book...
Forum: C++ 32 Days Ago
Replies: 3
Views: 146
Posted By Lerner
To my knowledge:

If you want to add an entirely new set of customer data to end of current data stored in file without overwriting current data, then you can open the file in app mode to append...
Forum: C++ 34 Days Ago
Replies: 3
Views: 340
Posted By Lerner
line 22 second program has out of bounds index used for S. If S has 4 elements, then the largest valid index is 3, as index values are zero based, meaning the first valid index is zero.

S...
Forum: C++ 34 Days Ago
Replies: 4
Views: 260
Posted By Lerner
Debug the code and find out why? If you aren't familiar with using debugging software then put temporary code in to output the value of tempValue and tempPtr->data after initial assignment of...
Forum: C++ 34 Days Ago
Replies: 8
Views: 240
Posted By Lerner
I would insert each term in terms in ascending order based on the exponent so that the exp term with exponent 0 has index 0 in terms, etc. I would expand terms if the exponent of a term to be added...
Forum: C++ 34 Days Ago
Replies: 4
Views: 260
Posted By Lerner
try moving line 19 to line 17 so you don't assign tempPtr->data to tempValue each time through the loop. You only want to do that if the value of the conditional in the if statement is true.
Forum: C++ Sep 30th, 2009
Replies: 3
Views: 460
Posted By Lerner
Does it compile? Does it run? Does it perform and behave like you would expect? If so, good job!

Your posting skills could be improved, though. Look at the anouncements or get a bright light...
Forum: C++ Sep 30th, 2009
Replies: 3
Solved: file I/O
Views: 194
Posted By Lerner
The best thing to do is get a reference book, preferably hardcopy, though there are some online resources as well. In general you use filestream objects to read and write to files as opposed to an...
Forum: C++ Sep 29th, 2009
Replies: 3
Views: 172
Posted By Lerner
To my knowledge you can't specify what to inherit and what not. You either inherit the whole shebang or you don't inherit anything. I always am receptive to being shown wrong, and thereby learn in...
Forum: C++ Sep 29th, 2009
Replies: 2
Views: 263
Posted By Lerner
First, don't use void as return type for main(), even if your compiler allows you to do it. The return type of main() should always be int.

Second, if you're at index i and there are three...
Forum: C++ Sep 29th, 2009
Replies: 2
Views: 367
Posted By Lerner
Declare a maze that will consist a 12 by 12 board represented internally by a 2D char array. The characters in the array will be # to indicate walls, space char to indicate available choices...
Forum: C++ Sep 28th, 2009
Replies: 16
Views: 373
Posted By Lerner
An alternate form of a alter/set/mutate method culled from InputInfo() could be:
void setM_sResName()
{
cout << "Enter a text name for the CResistor object being created."<<endl;
cin >>...
Showing results 1 to 40 of 1000

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC