Forum: C++ Sep 7th, 2007 |
| Replies: 2 Views: 733 I think you have to do something like this because int** isn't a compatible type with void**.
int i = 123;
int *p = &i;
void pop( void **data ) {
*data = p;
}
int main() { |
Forum: C++ Sep 6th, 2007 |
| Replies: 38 Views: 3,079 You have to be careful here. 'By reference' could mean two things, and only one of them is right. ;) Thef irst by reference is an actual reference in C++ and arrays are not passed by that reference... |
Forum: C++ Sep 6th, 2007 |
| Replies: 38 Views: 3,079 toppings[z] = a[z] ;
If a is declared as a plain int, why are you subscripting it like an array of int? I think you should make the whole thing an array and that'll fix your problem.
void... |
Forum: C++ Aug 30th, 2007 |
| Replies: 5 Views: 885 I hope you're not surprised that intel's compiler has better optimizations because they _make_ the processors, and not because you just don't like microsoft. ;) |
Forum: C++ Aug 22nd, 2007 |
| Replies: 6 Views: 2,980 I ran your code, Bench, but it doesn't do what gaggu82 asked for. It finds the search string even if it's embedded in another word, like "this is a string" prints "is is a string" instead of "is a... |
Forum: C++ Aug 22nd, 2007 |
| Replies: 6 Views: 2,980 There might be a way in the STL to do it, but I don't know. I'd write a search function that finds every occurrence of "is" and then checks to see if the first and last letters are on a word... |
Forum: C++ Aug 20th, 2007 |
| Replies: 13 Views: 1,816 I don't know much about boost.pool, but unless it does all of the work for you then you will have to implement your own allocator.
If you need to override the default destructor, it's not... |
Forum: C++ Aug 20th, 2007 |
| Replies: 13 Views: 1,816 You can handle memory by storing it all in one big block and passing out chunks just big enough for each node. Then freeing it turns into just one call to delete. But that doesn't call destructors... |
Forum: C++ Aug 20th, 2007 |
| Replies: 13 Views: 1,816 What do you mean by making the data structure heavier? You have to free the memory and to free the memory you have to visit every node. The only heavy thing about the clean function is that it uses... |
Forum: C++ Aug 16th, 2007 |
| Replies: 9 Views: 1,908 I think you'd be better off trying to separate the common stuff that both apps use into a dll and then having both apps reference the dll. What exactly do you need to do this for anyway? |
Forum: C++ Aug 15th, 2007 |
| Replies: 5 Views: 1,382 That's the same thing I suggested except it's too specific to the problem. If this is homework then a good next project is to generalize the problem into a number of any length or to change the... |
Forum: C++ Aug 15th, 2007 |
| Replies: 5 Views: 1,382 Ok, here are a few hints that you can bring together to do the program.
1: You can find the right side (least significant) digit for a number in any base by saying number % base. If the number is... |
Forum: C++ Aug 2nd, 2007 |
| Replies: 7 Views: 1,583 Make a shortcut to your exe and from the properties of the shortcut you can set a shortcut key. Pick any key you want, like y, and the shortcut to run the link will be ctrl+alt+y. |
Forum: C++ Aug 2nd, 2007 |
| Replies: 7 Views: 1,583 If you want to use the exe itself, no. If you're ok with making a shortcut to the exe then you can set a shortcut key that lets you type ctrl+alt+<your key> to open the program. |
Forum: C++ Jul 24th, 2007 |
| Replies: 5 Views: 1,075 State means that info persists between calls. If you want to keep a running total of some statistic, that's state, and it's hard to maintain with functions. You have to use a global variable or a... |
Forum: C++ Jul 19th, 2007 |
| Replies: 6 Views: 739 I compiled it and everything's like I said. Change how you create Output then change how you call it. I also added a body for push so that it runs, I hope you don't mind.
//Program to demonstrate... |
Forum: C++ Jul 19th, 2007 |
| Replies: 6 Views: 739 Right. You prototype Output to take a T and try to pass a Stack<T>. I guess you'd call it like this for the two different functions I wrote.
// Output takes a T parameter
dStack.Output(... |
Forum: C++ Jul 19th, 2007 |
| Replies: 6 Views: 9,291 |
Forum: C++ Jul 19th, 2007 |
| Replies: 6 Views: 739 From the prototype I'd guess this.
template<class T>
void Stack<T>::Output(T element)
{
cout<< element;
}
I don't understand why you have a parameter. It seems you want to output the... |
Forum: C++ Jul 18th, 2007 |
| Replies: 14 Views: 3,342 All you want to do is find the maximum of each row? You already have a function that finds the maximum of a single row, why can't you call it on each row in a loop?
#include <cstdlib>
#include... |
Forum: C++ Jul 18th, 2007 |
| Replies: 14 Views: 3,342 Everybody doesn't think in code, and that example is pretty vague.
When you loop over a 2D array, you use two loops, right? One loop on the outside goes over the rows and another on the inside... |
Forum: C++ Jul 18th, 2007 |
| Replies: 5 Views: 976 I just did to be sure. I got the same errors and changing privite to private fixed everything. |
Forum: C++ Jul 18th, 2007 |
| Replies: 5 Views: 976 The error says it all. private is misspelled. |
Forum: C++ Jul 17th, 2007 |
| Replies: 3 Views: 1,443 Is Cstring a class? If it lets you get an individual character and the size, you can do this easy.
char MiddleCharacter( Cstring string ) {
return string[string.length() / 2];
}
A char... |