Jump to content

  • Log In with Google      Sign In   
  • Create Account

pulpfist

Member Since 01 Nov 2005
Offline Last Active Jan 29 2013 04:02 AM

Topics I've Started

Unfamiliar C construct

26 October 2010 - 01:31 AM

I have been porting some libraries to D lately and I have stumbled over a C construct I haven't encountered before. It looks something like this:

typedef struct some_type_t some_type_t; // Opaque structure containing everything needed...

What is the difference between this construct and the more common

typedef struct some_type_t {}

What do they mean by opaque in this context? Where does it get populated with fields? What benefits is there to making such opaque constructs?

Thanks

[Edited by - pulpfist on October 26, 2010 7:50:25 AM]

Alternatives to C++

19 January 2010 - 12:43 AM

Out of mere curiosity I have been looking for possible alternatives to C++. Beginners constantly get the advice to pick up something else than C++ and it made me think what alternatives really exists. I consider the following to be a minimum for a C++ alternative: 1. Compiles native code for the most common platforms. 2. Does not require any kind of virtual machine 3. Main stream compiler must be avaliable free of charce Armed with this list I have managed to come up with only a few alternatives: 1. C Fast executables. Predecessor of C++. Usually not considered a better beginners choice in these forums 2. ocaml Fast executables, Functional, Lack of support/compability with certain platforms, Sparse dokumented, Somewhat awkward syntax 3. Haskell Pretty much the same as ocaml but sweeter syntax and does not produce quite that fast executables 4. D Dont know much about this one really. Can Digitalmars be trusted? Is this language on its way in or out of the loop? I have to say I'm not all that impressed by the alternatives I have found so far. They are few, C and D(?) are the only procedural langauge alternatives I think Is there other alternatives that has good documentation and support like C++ does?

[C++] Avoid duplicate code in class hierarchy

12 January 2008 - 07:07 AM

class Vehicle { ... };

class Bike : public Vehicle { ... };
class MotorBike : public Bike { ... };

class GliderPlane : public Vehicle { ... };
class Plane : public GliderPlane { ... };
At this point I want to add engines to some of the vehicles like MotorBike and Plane. The options I see here is to add a engine object to each class that should have one, but that would probably result in a lot of duplicate code. What I realy want to do is to add another layer, something like this
class Vehicle { ... };

class VehicleWithEngine : public Vehicle  { ... };
class VehicleWithoutEngine : public Vehicle  { ... };

...
But that is even worse, now I can't let MotorBike inherit from Bike anymore which seemed to make sense in the first case. Is there a common way to make the pices fall into place here? Can refactoring, multiple inheritance or something like that provide a solution, or is a class hierarchy just not suited for this?

So what happened to Lessbread anyway?

19 December 2007 - 12:27 PM

What happened to Lessbread and he's knockled sandwiches?

Sigh...

14 June 2007 - 06:42 AM

Whow, I got one of my threads closed for no apparent reason. I'm not going to whine about it but isn't it kind of lame to accuse someone you don't know for being a nazi? Need I remind you that Norway fought the nazis during WW2. My family is well known for being in the front line. Its just not an accusation I would like to have on my back. I suggest you guys loose the childish mindset. There is gazillions of ways to say that in a more straight up manner.

PARTNERS