Search Results

Showing results 1 to 26 of 26
Search took 0.01 seconds.
Search: Posts Made By: Radical Edward ; Forum: C++ and child forums
Forum: C++ Aug 30th, 2008
Replies: 1
Views: 1,653
Posted By Radical Edward
That's how a stack works, it's a "last-in, first-out" structure. The item at the top will always be the last item that was pushed:

#include <iostream>
#include <stack>

int main()
{
using...
Forum: C++ Aug 22nd, 2008
Replies: 3
Views: 1,759
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: 624
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 18th, 2008
Replies: 4
Views: 682
Posted By Radical Edward
One of Ed's favorite books is Inside the C++ Object Model (http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545). You're asking for a lot of hardcore low level info, and I doubt...
Forum: C++ Aug 11th, 2008
Replies: 1
Views: 369
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 11th, 2008
Replies: 9
Views: 3,324
Posted By Radical Edward
>still use strtol()
Better to use stringstream:

#include <ios>
#include <iostream>
#include <sstream>

int main()
{
using namespace std;
Forum: C++ Aug 10th, 2008
Replies: 4
Views: 745
Posted By Radical Edward
#import isn't available in C or C++, but if you want the same effect of it, some compilers implement a special #pragma for header files called once:

#pragma once

// Header contents

That's...
Forum: C++ Jun 16th, 2008
Replies: 4
Views: 421
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: 12
Views: 2,651
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: 514
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: 12
Views: 1,639
Posted By Radical Edward
> Meaning, if I opened up a table of contents, what would I look under to learn more about this subject.
Operator overloading, and probably stream I/O too. The exactly thing is overloading the...
Forum: C++ Jun 13th, 2008
Replies: 12
Views: 1,639
Posted By Radical Edward
> The char datatype is not guaranteed to be stored in a single byte, either.
char is guaranteed to equate to a byte, but a byte isn't guaranteed to be 8 bits. I think that's what you meant.
Forum: C++ Jun 9th, 2008
Replies: 6
Views: 884
Posted By Radical Edward
> But the following code is not working.c
Did you include the code for compose2? It's not a standard STL function, but Edward would guess that you mean to use the one defined in Nicolai Josuttis'...
Forum: C++ Jun 6th, 2008
Replies: 9
Views: 2,406
Posted By Radical Edward
> I have never in over 20 years seen anyone code a function prototype like that.
Edward has, but everyone has different experiences so there's no point arguing about what we've seen. :)

> Arrays...
Forum: C++ Jun 5th, 2008
Replies: 4
Views: 667
Posted By Radical Edward
The only real problem Edward sees is that you don't resize the dynamic array after the first call to AddFirst or AddLast. If you don't allocate the memory, you can't reliably write to it. Here is a...
Forum: C++ Jun 4th, 2008
Replies: 4
Views: 728
Posted By Radical Edward
> Why use getch() when there's a standard function: getchar()?
Because getchar() doesn't do what Edward needed.

getchar() is completely segregated from the console buffer such that the buffer...
Forum: C++ May 29th, 2008
Replies: 4
Views: 421
Posted By Radical Edward
Initializing numb is easy. Just start at 1 and double the last value until you get to the size of the array:

int k = 1;

for (int i = 0; i < 10; ++i) {
numb[i] = k;
k *= 2;
}
...
Forum: C++ May 27th, 2008
Replies: 20
Views: 36,040
Posted By Radical Edward
That's why Edward puts as much code as possible in namespaces. Compilers are bad about including all kinds of unexpected stuff in the standard headers, so even if you don't include unistd.h yourself,...
Forum: C++ May 15th, 2008
Replies: 5
Views: 478
Posted By Radical Edward
> there is no way to have separate classes from the class main()....
There isn't a class that contains the main function like in Java. main() is a global function and you can have it in a separate...
Forum: C++ May 8th, 2008
Replies: 34
Views: 2,348
Posted By Radical Edward
> What is so difficult to understand about this:
Is that a trick question? Of course it's difficult to understand if you haven't learned how it works yet. :-O Edward learned long ago that just...
Forum: C++ May 7th, 2008
Replies: 6
Views: 2,572
Posted By Radical Edward
Edward is guessing about how your tree interface is, but something like this makes sense if you're making a copy of the current tree and need a full tree in return:

//
// Non-recursive user...
Forum: C++ May 6th, 2008
Replies: 2
Views: 429
Posted By Radical Edward
You're printing the address of the pointer, not the address of the memory pointed to. Remove the address-of operator from your cout statement and you'll get the address of the memory that new gives...
Forum: C++ May 6th, 2008
Replies: 2
Views: 474
Posted By Radical Edward
> Horse h1(Distance(p));
This is an evil bug. C++ isn't seeing that line as an object definition, it's seeing the line as a function declaration. h1 is a function that returns a Horse object and...
Forum: C++ May 5th, 2008
Replies: 6
Views: 2,572
Posted By Radical Edward
> This should do what i want correct?
That's it. :) If you declare a pointer to BSNode<T>, that's all you have, a pointer. You can't reliably use that pointer until you set it to point to null or an...
Forum: C++ May 3rd, 2008
Replies: 6
Views: 1,546
Posted By Radical Edward
gydytojas is a struct, but you use it like an object. The problem is the same as if you tried to say int.value = 5;, and the fix is to define a variable of gydytojas to work with. :)
Forum: C++ May 2nd, 2008
Replies: 5
Views: 556
Posted By Radical Edward
You should abstract your data into objects so that it's easier to make changes and the design is clearer. Right now you have three vectors of data that should be encapsulated in a student class:
...
Showing results 1 to 26 of 26

 


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

©2003 - 2009 DaniWeb® LLC