Search Results

Showing results 1 to 40 of 93
Search took 0.01 seconds.
Search: Posts Made By: Radical Edward
Forum: C++ Aug 22nd, 2008
Replies: 3
Views: 1,700
Posted By Radical Edward
The only thing Edward can think of is using a union like that isn't required to work even if the conversion is safe but a reinterpret_cast<> is. The rules say that assigning to one member of a union...
Forum: C++ Aug 22nd, 2008
Replies: 5
Views: 618
Posted By Radical Edward
Sorry, Edward was accidentally using a Visual Studio extension. This should work:

#include <iostream>
#include <string>

class Field{
public:
virtual void display() = 0;
virtual int...
Forum: C++ Aug 22nd, 2008
Replies: 5
Views: 618
Posted By Radical Edward
// Star is in the wrong place
void Field::*data(){
return NULL;
}

// Star is in the wrong place
// void* is the wrong return type
void Field::*clone() const{
return NULL;
}
Forum: C Aug 19th, 2008
Replies: 4
Views: 1,669
Posted By Radical Edward
strtok ignores empty fields. Edward would recommend using another solution, like strcspn and some method of reading or copying a substring:

#include <stdio.h>
#include <string.h>

int main()
{...
Forum: C++ Aug 18th, 2008
Replies: 2
Views: 382
Posted By Radical Edward
The starting form is the first form that's opened. If you're using code generated by the new project wizard there will be a *.cpp file named the same as your project. That's where main() is, and in...
Forum: C++ Aug 17th, 2008
Replies: 8
Views: 1,649
Posted By Radical Edward
Edward's first guess without seeing the code is that you corrupt your memory somewhere and Vista is better at catching it with a hard failure, or you're just getting lucky on XP. But without seeing...
Forum: C Aug 16th, 2008
Replies: 2
Views: 380
Posted By Radical Edward
break from the inner loop and then continue from the outer loop. If there's more to the body, you may need a flag or something similar:

while (condition) {
int nextIteration = 0;

while...
Forum: C++ Aug 16th, 2008
Replies: 2
Views: 596
Posted By Radical Edward
To make a class act like an array you can overload the [] operator to simulate the same kind of indexing:

class myQueue {
public:
myQueue();
myQueue(const myQueue & CCqueue);
myQueue&...
Forum: C Aug 15th, 2008
Replies: 6
Views: 2,374
Posted By Radical Edward
EOF doesn't have an ASCII value, it's required to be negative:

#include <stdio.h>

int main()
{
printf("%d\n", EOF);
return 0;
}
Forum: C++ Aug 15th, 2008
Replies: 3
Views: 470
Posted By Radical Edward
#include is just a fun way of doing cut and paste. Separating code into header files shouldn't change how you use a class or make it less useful. :)

It doesn't, but using a namespace is a good...
Forum: C++ Aug 15th, 2008
Replies: 3
Views: 470
Posted By Radical Edward
How about storing those options in a singleton:

#include <iostream>
#include <string>

namespace EdRules {
using namespace std;

class GlobalOptions {
public:
Forum: C++ Aug 15th, 2008
Replies: 13
Views: 2,530
Posted By Radical Edward
If you don't mind Edward giving some constructive criticism, read on. :)

// This should never be in the global scope
using namespace std;

// Global variables should be avoided when possible...
Forum: C++ Aug 15th, 2008
Replies: 13
Views: 2,530
Posted By Radical Edward
>I get a error if I don't have ; after else statement, before sum = 0

else (number < 0)

The else statement doesn't have a condition; the condition is implied by the accompanying if and else if...
Forum: C++ Aug 13th, 2008
Replies: 4
Solved: scrollbox
Views: 729
Posted By Radical Edward
Put the picture box on a panel, and set the panel's AutoScroll property to true. Whenever the picture box's height or width exceeds the panel's height or width, scroll bars will automatically show up.
Forum: C++ Aug 13th, 2008
Replies: 4
Solved: scrollbox
Views: 729
Posted By Radical Edward
Assuming you mean Windows Forms, a lot of controls are scrollable, like TextBox and Panel. You can also inherit the ScrollableControl class and write your own if none of the existing controls work...
Forum: C++ Aug 12th, 2008
Replies: 4
Views: 564
Posted By Radical Edward
>I tried every specifier possible for fprintf but no result.
Ed's guess is that n->data is an std::string object, and this would solve the problem:

fprintf( HashTable, "\t%s " ,...
Forum: C++ Aug 12th, 2008
Replies: 4
Views: 564
Posted By Radical Edward
Why not use an ofstream to write to the file instead of fprintf and FILE pointers? If cout works just fprintf doesn't, it probably means that %s isn't the right specifier for n->data, but if you use...
Forum: C++ Aug 11th, 2008
Replies: 1
Views: 367
Posted By Radical Edward
The ideal way to do this is to encapsulate the data into an object that defines a comparison operator. Then you can sort the objects instead of trying to sort parallel arrays:

#include <algorithm>...
Forum: C++ Aug 10th, 2008
Replies: 7
Views: 1,335
Posted By Radical Edward
Edward would probably choose Java instead of C++ for a mobile phone.
Forum: C++ Jun 16th, 2008
Replies: 4
Views: 3,681
Posted By Radical Edward
If you don't mind two columns instead of two rows then this works:

void square(int integer)
{
int counter2 = 9;
while(counter2 >= 0)
{
cout << integer << '\t' << pow(integer,2.0) <<...
Forum: C++ Jun 16th, 2008
Replies: 4
Views: 3,681
Posted By Radical Edward
pow is overloaded for multiple types, and all of them can be converted to from int. An easy way to fix the problem is to force the second argument to double:

int square = pow(integer,2.0);
Forum: C++ Jun 16th, 2008
Replies: 4
Views: 419
Posted By Radical Edward
Ahh, yes, you're right. The problem is in the insertion method where you insert if either branch of the temp node is null. The tree should look like this:

(null)
19...
Forum: C++ Jun 16th, 2008
Replies: 4
Views: 419
Posted By Radical Edward
Your use of pointers seems a little backwards, but the tree in your sample program is valid. Ed used a formatted display algorithm to see how it's structured. Here's something that is a bit more...
Forum: C++ Jun 16th, 2008
Replies: 5
Views: 547
Posted By Radical Edward
> If I use the [] operator and return a reference, is there any way to mark that indice when a value is assigned to it?
It's your class, you can do anything you want internally. :) Edward would...
Forum: C++ Jun 16th, 2008
Replies: 12
Views: 2,576
Posted By Radical Edward
> That means, if one omits the for-init statement the semicolon also disappears.
That's not quite right, but Edward can easily see why you'd think that. Like most stuff in the standard, you have to...
Forum: C++ Jun 13th, 2008
Replies: 2
Views: 510
Posted By Radical Edward
Neither Matrix nor VNT need an explicit destructor, but the real problem is in the destructor for those two classes you try to delete objects that weren't returned by new:

> delete mat;
mat isn't...
Forum: C++ Jun 13th, 2008
Replies: 2
Views: 453
Posted By Radical Edward
You've commented out the definition of the copy constructor for Flight.
Forum: C++ Jun 13th, 2008
Replies: 4
Views: 426
Posted By Radical Edward
> Is the pop used for displaying and deleting the info in the stack or is there any other way to display the information.
It's up to you. :) The STL stack doesn't return the value with pop(), you...
Forum: C++ Jun 13th, 2008
Replies: 4
Views: 426
Posted By Radical Edward
> int top=1;
That shouldn't even compile. You can't initialize class or struct fields except in a few specific cases, and this isn't one of those cases.

> s.top=s.top+1;
> s.values[s.top]=x;...
Forum: C++ Jun 13th, 2008
Replies: 5
Views: 737
Posted By Radical Edward
> Perheps there could be an other way to disable it or prevent to press the button until it is finished.
Edward would probably use a processing flag while the calculation is running. Set the flag to...
Forum: C++ Jun 13th, 2008
Replies: 10
Views: 907
Posted By Radical Edward
> I have a class privately encapsulated in another class.
You can't access it except in the encapsulating class or friends of the encapsulating class. That's how private access works, and if you...
Forum: C++ Jun 13th, 2008
Replies: 5
Views: 737
Posted By Radical Edward
> Is it possible to not let the Form scroll down when running the code ?
It's hard to tell what your problem is without seeing all of the code, but to mitigate the effect of the problem you can move...
Forum: C++ Jun 13th, 2008
Replies: 5
Views: 454
Posted By Radical Edward
> but then how does it know which functions to use?
Functions can be overloaded on a template instantiation:

T Intersect(Point<2> a);
T Intersect(Point<3> a);

Or you can do the same thing as...
Forum: C++ Jun 12th, 2008
Replies: 5
Views: 454
Posted By Radical Edward
Ed was just thinking that if the interface can be molded to fit, you can do away with the separate explicit classes and use templates:

enum {X, Y, Z};

template <int Dim>
struct Point {
...
Forum: C++ Jun 12th, 2008
Replies: 5
Views: 454
Posted By Radical Edward
What's the difference between the 2 and 3 versions? How are Point2 and Point3 different, for example?
Forum: Computer Science Jun 10th, 2008
Replies: 3
Views: 1,511
Posted By Radical Edward
> How should I calculate the similarity between any two words?
The Levenshtein distance (http://www.merriampark.com/ld.htm) algorithm is a good place to start.
Forum: C++ Jun 9th, 2008
Replies: 11
Views: 1,600
Posted By Radical Edward
> When you mean "safe way", there is a way but it would be dangerous to put in it?
Sure, you can subtract the pointer itself from within SA's operator* and that will shift the range before your...
Forum: C++ Jun 9th, 2008
Replies: 11
Views: 1,600
Posted By Radical Edward
> Im sorry, Im not too sure what you mean.
If you create an object, SA<int>(10, 20), you can access index 15 even though there are only 10 elements. That's because the SA class forces the index back...
Forum: C++ Jun 9th, 2008
Replies: 11
Views: 1,600
Posted By Radical Edward
> Anything I did wrong?
You forgot to take the index shift into account. The matrix class supports N-based arrays, but the internal memory is still 0-based. You should subtract the low end of the...
Forum: C++ Jun 9th, 2008
Replies: 11
Views: 1,600
Posted By Radical Edward
> We know that *(*(k+i)+j) is equivalent to k[i][j].
> Is there a way to implement the same thing but with my matrix class?
Sure, but you have to do it by overloading all of the required operators....
Showing results 1 to 40 of 93

 


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

©2003 - 2009 DaniWeb® LLC