Search Results

Showing results 1 to 40 of 206
Search took 0.02 seconds.
Search: Posts Made By: grumpier
Forum: C++ Jan 16th, 2009
Replies: 5
Views: 882
Posted By grumpier
break statements can be used in looping constructs, and in switch/case blocks. They cannot be used to break out of an "if" block, or as an alternative means of returning from a function.

Also,...
Forum: C++ Jan 15th, 2009
Replies: 4
Views: 286
Posted By grumpier
::close() just means the function close() is within the global (unnamed) namespace.

In C++, if a function is not explicitly declared with a namespace, it is placed in the global (unnamed)...
Forum: C++ Jan 15th, 2009
Replies: 4
Views: 286
Posted By grumpier
You're using the function; presumably you can work out which header it came from. close() is not a standard function in C or C++.

I'm guessing it is a function related to sockets handling under...
Forum: C++ Jan 14th, 2009
Replies: 8
Views: 524
Posted By grumpier
I'd be betting on your side. But that just means he then needs to define the criterion for "The most efficient". For example, does it mean "fastest", "smallest number of machine instructions",...
Forum: C++ Jan 14th, 2009
Replies: 8
Views: 524
Posted By grumpier
You're developing a realtime application, and don't know how to add values to elements of an array?????

Pull my other leg: it'll play a tune for you.

What is the criterion by which you would...
Forum: C++ Jan 14th, 2009
Replies: 4
Views: 443
Posted By grumpier
Indeed. 'p' || 'P' would expand to a bool value of true, as will 's' || 'S'. Compilers will generally refuse to compile the above, as particular cases of a switch statement are not allowed to be...
Forum: C++ Jan 13th, 2009
Replies: 16
Views: 888
Posted By grumpier
Mathematical operations: operators like * (multiplication), + (addition), - (subtraction or negation), / (division), etc.

Splitting up large number and assigning them to an array of ints is one...
Forum: C++ Jan 13th, 2009
Replies: 16
Views: 888
Posted By grumpier
You can implement a class type that has the attributes you want (or find such a class type that someone else has implemented). Internally, that type might use an array of integers or (as...
Forum: C++ Jan 12th, 2009
Replies: 7
Views: 644
Posted By grumpier
If n is 1, then the set is {0, 1}.

If you have a set for n, the set for n+1 can be generated by appending a 0 and then a 1 to all elements of the set n.

For example, the set for n = 2 will be...
Forum: C++ Jan 12th, 2009
Replies: 16
Views: 888
Posted By grumpier
Generally, you cannot. The contents of limits.h generally reflects technical limits on capability of your compiler on your target operating system. Most compilers will need to be...
Forum: C++ Jan 11th, 2009
Replies: 4
Solved: casting
Views: 383
Posted By grumpier
An explicit conversion is what you're calling a cast. An implicit conversion is a conversion between types that the compiler allows or performs, even if you don't do a cast. For example;

...
Forum: C++ Jan 11th, 2009
Replies: 4
Solved: casting
Views: 383
Posted By grumpier
As a general rule, yes you should.

An implicit conversion exists between int and size_t so, in rough terms, you shouldn't need an explicit conversion between them.

Note "explicit conversion" is...
Forum: C++ Jan 11th, 2009
Replies: 3
Views: 845
Posted By grumpier
Try this. Comments added explaining the reason for change from your code.

#include <iostream> // <iostream> is standard, <iostream.h> is not
#include <cstring> // need functions to...
Forum: C++ Jan 11th, 2009
Replies: 6
Views: 1,097
Posted By grumpier
You have a description of one possible approach; consider coding it up as an exercise.
Forum: C++ Jan 11th, 2009
Replies: 6
Views: 1,097
Posted By grumpier
The whole point of Dijkstra's algorithm is to find a least cost (or shortest, in your case) path.

Once you have a first path, eliminate one of the nodes (C2, C5, or C10 in your example) on that...
Forum: C Jan 10th, 2009
Replies: 26
Views: 1,167
Posted By grumpier
I can, but I won't. As horrifying as the concept clearly is, you need to apply some effort to understand the answers you've been given.
Forum: C Jan 10th, 2009
Replies: 26
Views: 1,167
Posted By grumpier
You need to put some effort into understanding the answers you receive, rather than giving up if you're not given code examples.

The approach with using pointers is;

SomeTypeA Function(...
Forum: C Jan 10th, 2009
Replies: 26
Views: 1,167
Posted By grumpier
A common way of return multiple values is by returning a struct which has multiple members, or for the function to accept a pointer that receives additional data from the function.

You don't...
Forum: C++ Jan 9th, 2009
Replies: 6
Views: 1,479
Posted By grumpier
My guess is that IMG_GetError() is throwing an exception.

However, it's hard to say, as you haven't provided a complete example. You've paraphrased where your think the problem is.

Try...
Forum: C Jan 9th, 2009
Replies: 7
Views: 856
Posted By grumpier
Maybe so, but that doesn't make it a good idea.

If your function assigns *outputbuffer to something to something that is not a char *, and then main() dereferences it, the result is undefined...
Forum: C++ Jan 9th, 2009
Replies: 3
Views: 2,533
Posted By grumpier
As a matter of fact, your code isn't valid C either. If you are going to ask for help in converting C code to C++, it helps if you post working C code.

You need to read this thread...
Forum: C++ Jan 5th, 2009
Replies: 11
Views: 597
Posted By grumpier
You're making a distinction that doesn't exist. The Pythagorean Theorem is basic trigonometry.
Forum: Geeks' Lounge Jan 4th, 2009
Replies: 1
Views: 557
Posted By grumpier
The cleaning lady?

Seriously, it is necessary to assume the houses are ordered 1-5 (first to fifth) from left to right. Then a bit of persistence with eliminating anything that contradicts any...
Forum: C++ Jan 3rd, 2009
Replies: 3
Views: 698
Posted By grumpier
Firstly, there is no space between the closing bracket at the end of FOR(x,n) and preceding the rest. That's a stylistic concern, but badly hurts readability.

Second, and more significantly,...
Forum: C Jan 2nd, 2009
Replies: 3
Views: 827
Posted By grumpier
What can I say? I was tired. My sig also applies.
Forum: C Jan 2nd, 2009
Replies: 3
Views: 827
Posted By grumpier
The first line puts a space into the first char of a, and a zero into the second char. All other elements of a are uninitialised. Hence the compiler diagnostic (which will usually be a warning,...
Forum: C++ Jan 1st, 2009
Replies: 6
Views: 879
Posted By grumpier
I'd look in the glut header files before looking in the cstdlib. The fact there is even a macro GLUT_BUILDING_LIB to define to "stop a clash between glut and stdlib" says that the incompatibility...
Forum: C++ Dec 31st, 2008
Replies: 6
Views: 879
Posted By grumpier
Of more relevance, try posting a small sample of your code that illustrates the problem. Also provide information about your compiler settings (eg any settings you've tweaked in the VC IDE to...
Forum: Geeks' Lounge Dec 31st, 2008
Replies: 5
Views: 366
Posted By grumpier
It has to be. If guys and gals actually paid attention to what the other is really like, they would run a mile. Love is therefore nature's way of bringing members of the opposite sex together so...
Forum: C++ Dec 31st, 2008
Replies: 3
Views: 352
Posted By grumpier
A starting point for you would be to specify what atomic_add_int_nv() actually does under unix. Forum readers are not mind-readers, and not generally all that good at working out what arbitrarily...
Forum: C++ Dec 31st, 2008
Replies: 5
Views: 462
Posted By grumpier
That's not true. A pure virtual function can be defined (i.e. it can have a function body).

In C++, the "=0" in the declaration is what makes the function pure virtual. In C++, a class with...
Forum: C++ Dec 31st, 2008
Replies: 5
Views: 723
Posted By grumpier
To give you a clue about what's happening, 100! is about 9.3 by 10^157. To represent that, a 525 bit integer is needed (and that increases 530 bits to represent 101!). 64 bit is nowhere near...
Forum: C++ Dec 30th, 2008
Replies: 6
Views: 342
Posted By grumpier
You need to be careful with executable compression. Compressed executables have some characteristics associated with self-modifying code (the decompression stub unpacks code and data into memory). ...
Forum: C++ Dec 30th, 2008
Replies: 6
Views: 342
Posted By grumpier
std::cout and the streaming to it involve functions from the C++ standard library.

As to libraries to use/avoid to minimise executable size, there's no single correct answer. As Salem said, when...
Forum: C++ Dec 29th, 2008
Replies: 3
Views: 671
Posted By grumpier
If the content of header A relies on content of header B, then it is generally a good idea for header A to #include header B. Examples of "relies on" are;

- header B declares a base class, and...
Forum: C Dec 29th, 2008
Replies: 3
Views: 402
Posted By grumpier
If by ``"c" programme'' you mean something that is compliant with one or both of the C standards, then there's only one answer: it's impossible. Your not wanting such an answer does not make it...
Forum: C++ Dec 28th, 2008
Replies: 4
Views: 1,456
Posted By grumpier
The short answer is that you can't. The system() function (it's not a command) supported by win32 compilers/libraries starts up a command shell, and that command shell shows the "black command...
Forum: C++ Dec 27th, 2008
Replies: 8
Views: 467
Posted By grumpier
Sorry, that statement strikes me as gibberish.

The declaration "static int num;" within the body of class number simply tells the compiler that a single integer named number::num exists somewhere...
Forum: C++ Dec 27th, 2008
Replies: 15
Views: 2,429
Posted By grumpier
You need to understand the difference between registering a callback function and actually calling it.

Setting TButton's OnClick event egisters a function that will be called when the user -...
Forum: C++ Dec 27th, 2008
Replies: 8
Views: 467
Posted By grumpier
Narue answered that already.

The "static int num;" within the body of class number declares the static member. The statement outside the class body "int number::num;" defines it.

Declaring a...
Showing results 1 to 40 of 206

 


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

©2003 - 2009 DaniWeb® LLC