class-members

Why are "inlined" static consts not allowed, except ints?

Possible Duplicate http://stackoverflow.com/questions/370283/why-cant-i-have-a-non-integral-static-const-member-in-a-class struct Example { static const int One = 1000; // Legal static const short Two = 2000; // Illegal static const float Three = 2000.0f; // Illegal static const double Four = 3000.0; // Illegal ...

How to access class members from an array of class variables?

I want to use PHP's reflection features to retrieve a list of parameter names from a method. I have a class like this: class TestClass { public function method($id, $person, $someotherparam) { return; } } I can get the list using code like this: $r = new ReflectionClass('TestClass'); $methods = $r->getMethods(); for...

Object oriented design suggestion

Here is my code: class Soldier { public: Soldier(const string &name, const Gun &gun); string getName(); private: Gun gun; string name; }; class Gun { public: void fire(); void load(int bullets); int getBullets(); private: int bullets; } I need to call all the member functions of Gun over a Soldier object. Some...

Visual Studio IntelliSense - IHideObjectMembers trick doesn't work. What am I missing?

The IHideObjectMembers trick can be used e.g. in fluent interface implementations to hide System.Object members from IntelliSense. (If you don't know this trick, you can read up on it via the above link; I'm just repeating the interface's usual declaration here:) using System; using System.ComponentModel; [EditorBrowsable(EditorBrowsab...

What is the right way to put a smart pointer in class data (as class member) in C++?

Suppose I have a class Boda: class Boda { ... }; And I have a member cydo in this class that I want to be a smart pointer (that is, I want it to get deallocated automatically as soon as the class gets destroyed). I am using Boost's smart pointers, so I write: class Boda { boost::shared_ptr<int> cydo; public: Boda...