1,608 Posted Topics

Member Avatar for DragonReborn225

put a semicolon after the closing bracket of the declaration of the struct and recompile. More importantly, never, ever, write the whole program and then hit the compile button. You're asking for a pain in the neck. Write a single class method or nonclass function one at a time and …

Member Avatar for Lerner
0
169
Member Avatar for Foe89

you don't initialize title etc before outputting the variable so they have random, junk values. You don't need them anway. You want to use the dot operator to output the appropriate member variables of the object you sent to the function. You also need to give the function definition the …

Member Avatar for Lerner
0
162
Member Avatar for PaladinHammer

change array to be of type string, not type int. to evaluate/scan/print an array backward start with the largest valid index used and decrement the index each time through the loop instead of increment from the beginning.

Member Avatar for PaladinHammer
0
232
Member Avatar for delner

you could try looking up forward declarations in your favorite reference material, though without knowing more details about the program my first thought is whether you should redo the heirachy/class relationships to avoid the entanglement completely if possible.

Member Avatar for Alex Edwards
0
74
Member Avatar for PaladinHammer

I explained how to do it in your other thread. Use a loop with an int counter that starts at the highest valid index and decrements the counter by one each time through the loop, just like if I told you to count backwards by one starting at 10 until …

Member Avatar for Lerner
0
95
Member Avatar for afg_91320

Do it the old fashioned way. Write one functon at a time. Test the function to make sure it works in addition to it being able to compile. Then move on to the next function. If you have no idea what a selection sort and a binary search are then …

Member Avatar for Lerner
0
117
Member Avatar for mybluehair

The two tasks are related. Each element of the array is an instance of that type and can be acessed using an index within the [] operator. [code] const int MAX = 3 int example[MAX]; for(int i = 0; i < MAX; ++i) { cin >> example[i]; } for(int j …

Member Avatar for Lerner
0
70
Member Avatar for dusse

A vector of vectors of STL strings instead of an array of arrays might be better since STL strings usually aren't length limited as is required by arrays. I think this is the correct syntax for that. (Keep spaces between the angled braces so the compiler doesn't think you are …

Member Avatar for Lerner
0
116
Member Avatar for anbuninja

>>if (package != 'A' || package != 'a') The OR operator returns true if either side of the operator is true. Since package can not be both 'A' and 'a' at the same time the that snippet must always equate to true. On the other hand the AND operator only …

Member Avatar for WaltP
0
140
Member Avatar for jesseb07

You could use modf() to get the decimal portion. Then you can convert the decimal into a string using a stringstream. Then you can turn the string into a long.

Member Avatar for jesseb07
0
272
Member Avatar for Falkoner1

>>I'm trying to find a good, easy to use GUI for an inventory in my game, all I really want them to be able to do is select items, maybe move them around into different slots, and be able to modify variables based on where things are moved. Here's an …

Member Avatar for Freaky_Chris
0
103
Member Avatar for invisal

Try placing a line like: HINSTANCE Window::hInst; and initialize it with a default value if possible like a good little variable outside the class; after the closing semicolon of the class declaration and before declaring main().

Member Avatar for invisal
0
245
Member Avatar for JustLearning
Member Avatar for Lerner
0
669
Member Avatar for Trekker182

That might help. But before making the change I think you need to try to express the problem more clearly. Will the head node be considered position zero or position 1? For example, if list is 80->50 and you want 87 to be at position 2 do want the list …

Member Avatar for Trekker182
0
133
Member Avatar for dexter1984

>>Any solutions to this? On the other hand, depending how you want to do things, do you even want to change the array values? You could make the change only if needed in a function. Say something like this:[code] void Date::operator++() //prefix increment operator { //....... if(monthNo == 2) if(day …

Member Avatar for dexter1984
0
121
Member Avatar for csaund1

There are several ways that can be done. One way is to add 0.5 (or a similar value depending on where you want to round) to the original value and then cast it to an int and then back again if you want to round to the nearest decimal value …

Member Avatar for ArkM
0
187
Member Avatar for NinjaLink

You should loop through the list from within the function, checking the value of each node using an if statement as you get to it, not just use an if statement without a loop.

Member Avatar for NinjaLink
0
203
Member Avatar for n3XusSLO

Where's the function? Wouldn't the {}s be ignored since there is no function or if statement or control loop associated with the {}s to generate a new scope?

Member Avatar for Lerner
0
192
Member Avatar for localp

>>please send the header #include<list> >>STL member functions used here's a listing of the member functions with examples: [url]http://www.cppreference.com/wiki/stl/list/start[/url] >>then we gotta sort (alphabatical order), b4 presenting to the user.. On first blush that seems to defeat the purpose of the hash table?

Member Avatar for Lerner
0
187
Member Avatar for guest7

Four "options" I can think of. 1) My first choice would be to use different type of container. I say this because I don't think of looping through a stack to evaluate the contents. To my knowledge the only element that is routinely available to view in a stack is …

Member Avatar for Lerner
0
72
Member Avatar for rhoit

I don't have a lot of experience with templates but based on your other function declarations/definitions, which presumably work, have you tried something like this: template <class Dtype> Nodeptr Stack<Dtype>::search(Dtype item) for the first line of the definition of search()?

Member Avatar for Lerner
0
171
Member Avatar for mrrko

Don't know about your logic, but this syntax is wrong: if (isAM_par = true) = is assignment and you want equality which is ==. This mistake is repeated many times throughout the program.

Member Avatar for Lerner
0
89
Member Avatar for MylesDBaker

To get displayPoint() to work you can let it use an arbitrary ostream object, like cout, or maybe a stream to write the Point to a file instead of to the stream. This stream object should be passed to the displayPoint() as a parameter after it's been declared somewhere else, …

Member Avatar for Lerner
0
201
Member Avatar for DLightman

If you can successfully output the contents of the array before passing it to bubblesort, then within bubblesort() you could try outputting the array before trying to sort it to be sure it has been successfully passed to the function. If so then it seems liklely that the sorting problem …

Member Avatar for DLightman
0
88
Member Avatar for meddlepal

output name and course before sending them to strlow to be sure they have been read in correctly. If not, can you read the file called students when you open it in a text editor? If not how is the file called students created?

Member Avatar for meddlepal
0
91
Member Avatar for vladdy191

in main() the values of i and the elements of a remain unchanged since you are passing both parameters to swap() by value, not by reference. You know of course that you will need to declare an array of int called a before you could successfully compile and run the …

Member Avatar for Lerner
0
82
Member Avatar for bugmenot

[url]http://www.daniweb.com/forums/thread90228.html[/url] Look at this thread. It's a sticky (permanent) thread at the top of the opening page of this board/forum.

Member Avatar for Lerner
0
140
Member Avatar for afg_91320

This is initialization because all values in the array are set to zero or hello at time of declaration: int array[3] = {0}; char array[3][6] = {"hello"}; This initializes to different values at time of declaration: int array1[3] = {1, 2, 3}; char array[3][6] = {"joe", "deer", "car"}; When declaring …

Member Avatar for Lerner
0
3K
Member Avatar for DaveCachia

Since we're not yet in the age of Big Brother and we can't look over each others shoulders yet, please post relevant code.

Member Avatar for DaveCachia
0
99
Member Avatar for Mako-Infused

I would rethink the interface of the crypt class and specifically, the data members and constructors. Why should crypt have a string data member? Shouldn't the crypt object take a string input, encrypt/decrypt as indicated, and close? If you agree, then remove inCode from the class declaration, create a default …

Member Avatar for Mako-Infused
0
221
Member Avatar for thekevin07

You could consider reading the entire line in and then parsing it, or you could consider parsing it as you read it in. Either way, you will probably read the data into a series of strings and then convert to numerical data types as desired. You could use getline() using …

Member Avatar for Lerner
0
345
Member Avatar for daviddoria

To my knowledge, the only way to use the same version of << for both classes would be if they output exactly the same information about both classes. In that case you might be able to put the << operator in a base class and then let both classes inherit …

Member Avatar for Lerner
0
187
Member Avatar for daviddoria

If each class derives from the same base class inheriting virtual functions then it may be possible to do something with pointers that looks vaguely like:[code] class base virtual A() virtual B() virtual C() class V : public base A() B() C() class C: public base A() B() C() int …

Member Avatar for ArkM
0
131
Member Avatar for drdolittle

My first thought is because int** is not the same as int[][], though the syntactic use of each is quite similar.

Member Avatar for grumpier
0
121
Member Avatar for Nick6425fl

In line 26 this: population (double birthRate, double deathRate, numYears, double n); is a function declaration, not a function call. Function calls don't list argument types, just argument names or argument values.

Member Avatar for Nick6425fl
0
120
Member Avatar for Nick6425fl

don't use a return statement at all when the function return type is void. [code] void printValue(int v) { cout << v; }[/code] or just say return with nothing listed after it but a semicolon, that should work too.

Member Avatar for VernonDozier
0
288
Member Avatar for Erica122883

I only looked at the code briefly, so there may well be other errors and I may have overlooked sections that address areas discussed below. 1) I don't see where totalCount is initialized to zero. Based on quick review of code it looks like this should probably be done in …

Member Avatar for Lerner
0
118
Member Avatar for riya1234

>>for post and pre order it showing wrong results Other than questonable indentation practices and some overuse of pointers in the insertion process I don't see any obvious logic errors visually. So. let's see if what you're expecting is what others would expect, too. Post a sample input using 4-6 …

Member Avatar for Lerner
0
147
Member Avatar for Richy321

In my book it's just another option. Once you get used to seeing the ? operator it isn't really that problematic. Most often its the fancy operators/conditions within the conditions that make it confuscated for me at least.

Member Avatar for Richy321
0
132
Member Avatar for cherryteresa

To me the problem boils down to how many of each of the 3 char are there in the array. I find: 1 e 2 t 3 s So I'd loop through the array looking at each char and see if it equals one of those three values displaying each …

Member Avatar for cherryteresa
0
141
Member Avatar for inumbris

If you had a pointer to the '9' in the original string you could potentially change the original string. Therefore, since the original string is const, any pointer pointing to any part of the original string should also be const.

Member Avatar for Lerner
0
141
Member Avatar for kotkata

seed the generator just once at the start of the program, not every time you call random. Since the time it takes the computer to do the separate function calls is so short there isn't enough time to make a difference in the seeding so it's seeding with the same …

Member Avatar for Lerner
0
97
Member Avatar for ROTC89

throw in some output statements within your code to see what top is after each push to be sure you are actually putting something in the stack. I'm concerned that you declare the stack using type int but you are trying to push type char onto the stack. That also …

Member Avatar for ROTC89
0
260
Member Avatar for McCo

flush() is for use with output streams only. It is not to be used on input streams. I/O is buffered in C++ and flush() forces an output to an appropriate variable clearing of the output stream buffer. There is no similar built in function for input streams, though you can …

Member Avatar for Lerner
0
124
Member Avatar for chunalt787

Well I don't know about you, but where I live it's a (minor) holiday evening and a Friday night to boot. I feel a little goofy even looking but just got done with some online stuff for work, so here I am. Given your description I 'd comment everything about …

Member Avatar for chunalt787
0
111
Member Avatar for JackDurden

you are starting temp at the beginning of the list each time through. I'd consider setting temp to the beginning of the list outside the function, then pass the item, the position and temp to the function. The terminating condition could be that the value of item is found in …

Member Avatar for skatamatic
0
105
Member Avatar for DemonGal711

>>Is the throw really needed No. It is one way to try to handle errors gracefully. You can write functional stacks without using throw (and the associated try/catch) statements. If you want to learn a little something about try/catch/throw and how it can be used to handle errors/exceptions then the …

Member Avatar for DemonGal711
0
99
Member Avatar for Niner710

Another option would be to use a stringstream to parse the line once it's been read in using getline().

Member Avatar for Lerner
0
211
Member Avatar for cam875

IMO, serial ifs should be used if you want every condition to be checked. if/else/else ifs are used if you want to stop once one of the conditions is positive and don't need to assess any further conditions. Global scope means any program/code can open your code and use/change the …

Member Avatar for ddanbe
0
163
Member Avatar for DGeneral

I'll let others more knowledgable than me comment on your logic but I will make a couple observations on your syntax. char *c; if(c == "\n") You can't compare C style strings using the == operator. You have to use a strcmp() function, or roll your own. fis >> str; …

Member Avatar for Ancient Dragon
0
183

The End.