Search Results

Showing results 1 to 30 of 30
Search took 0.01 seconds.
Search: Posts Made By: grumpier ; Forum: C++ and child forums
Forum: C++ Jan 14th, 2009
Replies: 8
Views: 545
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: 545
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 11th, 2009
Replies: 4
Solved: casting
Views: 408
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: 408
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: 1,012
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++ Dec 29th, 2008
Replies: 3
Views: 806
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 27th, 2008
Replies: 15
Views: 2,796
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 26th, 2008
Replies: 15
Views: 2,796
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 17th, 2008
Replies: 6
Views: 1,316
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...
Forum: C++ Dec 15th, 2008
Replies: 4
Views: 499
Posted By grumpier
That statement is inaccurate on so many levels that I'm speechless. Non-virtual functions can also be overridden, but the behaviour differs from overridden virtual functions due to "name hiding", as...
Forum: C++ Dec 13th, 2008
Replies: 5
Views: 460
Posted By grumpier
In an ideal world, where compiler vendors care about perfectly diagnosing all errors in code, yes. In the real world, where compiler vendors prefer to focus attention on other things (eg...
Forum: C++ Dec 10th, 2008
Replies: 3
Views: 2,229
Posted By grumpier
It is necessary for the derived class to override all inherited pure virtual functions, otherwise the derived class remains an abstract class.
Forum: C++ Dec 10th, 2008
Replies: 3
Views: 2,229
Posted By grumpier
Provide a small but complete example of code that exhibits your problem.

Your code sample and description is not complete, and the cause of the error is probably in something you haven't shown or...
Forum: C++ Dec 4th, 2008
Replies: 2
Views: 287
Posted By grumpier
Your problem is actually the first four lines of the main() function. I've added comments to the code that are related to problems on each line.

void main() // main should return int, not...
Forum: C++ Nov 30th, 2008
Replies: 3
Views: 503
Posted By grumpier
The C++ standard explicitly allows compilers to eliminate temporary objects if the only way of detecting if those temporary objects exist is to track constructor and destructor calls.

A special...
Forum: C++ Nov 27th, 2008
Replies: 8
Views: 836
Posted By grumpier
Your main.cpp needs to have visibility of the definition of the conversion (or cast) operator. In other words, the implementation of the operator needs to be inlined into the vector.h: otherwise...
Forum: C++ Nov 26th, 2008
Replies: 2
Views: 337
Posted By grumpier
You are making the mistake of assuming that integer division yields a floating point result - it doesn't: it yields an integer result and integers can't represent fractions.

In your code i/2231...
Forum: C++ Oct 30th, 2008
Replies: 4
Views: 452
Posted By grumpier
If there are common things that all classes which handle triangles have to do, put those functions into their own class (eg TriangleModelFile derived from ModelFile). Derive the specific/multiple...
Forum: C++ Oct 30th, 2008
Replies: 4
Views: 452
Posted By grumpier
Don't use the first option. The whole point of a Base class is capturing functionality that is common to all derived classes.

As to the second option, there are many ways. Such as....
...
Forum: C++ Oct 18th, 2008
Replies: 2
Views: 444
Posted By grumpier
Your function highestTest() does not initialise the variable "highest", but the first operation involves comparing its value with elements of the array. That means the value it ends up with in...
Forum: C++ Oct 5th, 2008
Replies: 4
Solved: vector <char*>
Views: 3,944
Posted By grumpier
When you append pointers onto a vector of char, the pointer is copied. You are expecting the data the pointer points at to be copied.

With a vector<char *> you need to explicitly copy the data...
Forum: C++ Sep 29th, 2008
Replies: 24
Views: 2,977
Posted By grumpier
Well, I could. But that takes the challenge of problem solving away from you.

Look back in my previous posts in this thread for definition of T, n, etc.

VernonDozier has worked out what I'm...
Forum: C++ Sep 28th, 2008
Replies: 24
Views: 2,977
Posted By grumpier
Start with T(0) = 1.

In a loop use the fact that T(n+1) = x*T(n)/(n+1) to compute each term. Add the terms together.
Forum: C++ Sep 28th, 2008
Replies: 24
Views: 2,977
Posted By grumpier
Oh, please! Huge integer libraries or strings are needed for some things, but falling back on them for basic problems like this is crazy.

The program can go to much higher terms simply using the...
Forum: C++ Sep 25th, 2008
Replies: 7
Views: 560
Posted By grumpier
No .... you mean your tests did not detect a problem. Your tests will only check things you think to test. If you didn't anticipate the particular problem that is occurring, a fault will get...
Forum: C++ Sep 25th, 2008
Replies: 7
Views: 560
Posted By grumpier
The cause of your problem is almost certainly code executed before your red lines are reached.

My guess - although you haven't shown them - is that the problems really occur in your input()...
Forum: C++ Sep 12th, 2008
Replies: 6
Views: 826
Posted By grumpier
Not even close.

You have declared myclass's length() method as taking one argument, and yourlen() calls it with two arguments.

Similarly, yourlen() is declared with no arguments, but when you...
Forum: C++ Sep 10th, 2008
Replies: 4
Views: 501
Posted By grumpier
In C++, recursive call of main is not allowed at all.

To answer the original question, if you must be able to execute a program that reads from standard input and writes to standard output, you...
Forum: C++ Sep 7th, 2008
Replies: 2
Views: 687
Posted By grumpier
Try closing outputfile before attempting to open it as an input file.
Forum: C++ Sep 2nd, 2008
Replies: 5
Views: 1,308
Posted By grumpier
Dragon's approach will work .... the only other obstacle is the fact that most systems allow a process to have only a small number of files open simultaneously. If you exceed that number, .....
Showing results 1 to 30 of 30

 


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

©2003 - 2009 DaniWeb® LLC