Search Results

Showing results 1 to 40 of 148
Search took 0.01 seconds.
Search: Posts Made By: grumpier ; Forum: C++ and child forums
Forum: C++ Jan 16th, 2009
Replies: 5
Views: 1,069
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: 297
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: 297
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: 542
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: 542
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: 471
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: 969
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: 969
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: 715
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: 969
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: 404
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: 404
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: 980
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,325
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,325
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 9th, 2009
Replies: 6
Views: 1,680
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: 3
Views: 2,866
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: 640
Posted By grumpier
You're making a distinction that doesn't exist. The Pythagorean Theorem is basic trigonometry.
Forum: C++ Jan 3rd, 2009
Replies: 3
Views: 804
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 1st, 2009
Replies: 6
Views: 1,028
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: 1,028
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: C++ Dec 31st, 2008
Replies: 3
Views: 402
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: 492
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: 805
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: 358
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: 358
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: 784
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 28th, 2008
Replies: 4
Views: 1,671
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: 490
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,700
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: 490
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...
Forum: C++ Dec 27th, 2008
Replies: 8
Views: 490
Posted By grumpier
It doesn't matter where you do it, as long as you obey the one-definition rule (ODR). Typical projects link together object multiple object files to create an executable, and each object file is...
Forum: C++ Dec 26th, 2008
Replies: 15
Views: 2,700
Posted By grumpier
TButton's constructor needs to be passed a pointer to a TComponent (eg a parent form) that is responsible for managing the button.

It is also necessary to set various attributes: position,...
Forum: C++ Dec 19th, 2008
Replies: 8
Views: 570
Posted By grumpier
scizj: Look at my previous post. Although I wrote it without having seen your full code, you will find the solution in to your problem within that post.
Forum: C++ Dec 19th, 2008
Replies: 8
Views: 570
Posted By grumpier
Presumably you have

#include <iostream>
using namespace std;

or something equivalent in the code before your class declaration. The #include directive is needed (if you don't have it, put it...
Forum: C++ Dec 19th, 2008
Replies: 4
Views: 669
Posted By grumpier
On the first loop iteration, the stream flags are set to defaults. That is not true for subsequent iterations.
Forum: C++ Dec 19th, 2008
Replies: 4
Views: 669
Posted By grumpier
The short answer is that ios::left and ios::right (and some others) are not mutually exclusive, but your code reflects an assumption that they are. It is possible to have both set simultaneously...
Forum: C++ Dec 18th, 2008
Replies: 5
Views: 375
Posted By grumpier
Not if efficiency is defined as competence in achieving the intended effect. This is a definition that may be found in english language dictionaries. ;)

But, seriously, ArkM is right: ...
Forum: C++ Dec 18th, 2008
Replies: 5
Views: 375
Posted By grumpier
I have four concerns with your code, in decreasing order of importance.

1) Your input requires five integers separated by spaces. What do you expect to happen if the user enters 26 27 88 72...
Forum: C++ Dec 17th, 2008
Replies: 6
Views: 1,282
Posted By grumpier
The only way in which a constructor can report an error is by throwing an exception.

The C++ standard has this to say (in Section 15.2 "Constructors and destructors" which is within Section 15...
Showing results 1 to 40 of 148

 


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

©2003 - 2009 DaniWeb® LLC