Object Class

C++ was my first language, but C# is my strongest language. In C#, if I wanted to create a dynamic class that could handle manipulation of any variable type, I would use Object as a parameter and return type and cast it appropriately. In C++, I know of no way to do this. Is there a solution, or is it just one of the many reasons I prefer C#?

Thanks,
Stauffski

Why do you want to do this? Bear in mind you only have 2 Kb of RAM, and 32 Kb of program space.

Rather than solving abstract problems like making variables of any type, let's solve a specific problem, like how to heat your house.

stauffski:
is it just one of the many reasons I prefer C#?

If you want a particular object to be treated in a particular way, then you typically want an interface. Interfaces in C++ are implemented using pure abstract base classes.
If you want just general argument-type-based polymorphism, then you build your class (or function) like a template.
Finally, if you really need a variant type, try boost::any -- it's a fine template that does variants very well.
However, I don't think boost is ported to the Arduino, so I highly recommend the dedicated template approach or interface approach.

Thank you for the input. I am working with the Arduino Mega 2560 so I'm not really concerned about space, but I broke down and went with the hard coding approach.

Thanks.

Sounds like another software person tries to do hardware the software way, with C# etc. The mega has 8K of SRAM and dynamically allocating memory isn't what it is made for. Is this question related with the menu question you had? Maybe reduce the complexity of your project. You can't address everything that a general purpose computer can do on a chip that is made to control your car or oven. It's like running MS stuff on a car. Not enough memory.

It is related but I am by no means concerned about running out of space in any dimension. I'm simply writing a library. It will be about 6000 bytes.

stauffski:
It is related but I am by no means concerned about running out of space in any dimension. I'm simply writing a library. It will be about 6000 bytes.

Have you seen the Netduino? Given that C# and the Micro .NET environment is its "native" development environment, it may be a better fit to your desires.
(Note that the Netduino Plus comes with Ethernet for cheaper than an Arduino + Ethernet Shield: http://www.amazon.com/Secret-Labs-Netduino-Plus/dp/B004FRZ4E6/ref=sr_1_1?ie=UTF8&qid=1318219030&sr=8-1 )