member

How do you use the non-default constructor for a member?

I have two classes class a { public: a(int i); }; class b { public: b(); //Gives me an error here, because it tries to find constructor a::a() a aInstance; } How can I get it so that aInstance is instantiated with a(int i) instead of trying to search for a default constructor? Basically, I want to con...

What is correct way to initialize a static member of type 'T &' in a templated class?

I'm playing around with an eager-initializing generic singleton class. The idea is that you inherit publicly from the class like so: class foo : public singleton<foo> { }; I've learned a lot in the process but I'm stuck right now because it's breaking my Visual Studio 2008 linker. The problem is with the static instance member and/or ...

how to pass a non static-member function as a callback?

io_iterator_t enumerator; kern_return_t result; result = IOServiceAddMatchingNotification( mNotifyPort, kIOMatchedNotification, IOServiceMatching( "IOFireWireLocalNode" ), serviceMatchingCallback, (void *)0x1234, & enumerator ); serviceMatchingCallback((...

Use Boost to get arity and paramerter types of member function? (boost::function_traits)

It works just fine, for plain vanilla functions. The code below works just fine. It prints just what is should: int __cdecl(int, char) 2 int,char #include <boost/type_traits.hpp> #include <boost/function.hpp> #include <boost/typeof/std/utility.hpp> #include <iostream> using std::cout; using std::endl; int foo(int, char) { retu...

Member Pointer to Base Class

Hi, all. I can't undestand why the bellow code need a cast to work. Someone can explain it? class Base { }; class Derived : public Base { }; class Class { public: Derived member; }; ... Derived obj; Base *ptrObj = &obj; // ok, no cast needed Derived Class::* ptr = &Class::member; // ok Base Class::* ptr = &Class::member; // ...

C++ member function applied to object

hi I want to call member function by passing it as template parameter, without using boost is possible. Here is an example off what I tried to do, class object { void method(); } { object object_instance; ... apply<object:: method>(); ... template<class F> void apply() { F(object_instance); } // want to call object_instance.F() } t...

Possible to fix/disable member groups FAIL when using Doxygen?

I develop an open-source Objective-C framework, and I use Doxygen to generate the documentation (http://dysart.cs.byu.edu/CHDataStructures). Overall, Doxygen does a nice job, but I have a perennial annoyance that I can't figure out for the life of me. I use the \name command and Member Groups to group methods by task (these Apple docs s...

C++ static template member, one instance for each template type?

Hi, Usually static members/objects of one class are the same for each instance of the class having the static member/object. Anyways what about if the static object is part of a template class and also depends on the template argument? For example, like this: template<class T> class A{ public: static myObject<T> obj; } If I would c...

How do I declare the size of a string array if it's a member function.

I have a problem with setting the size of my array. In my code I have: class Test { public: ....//Functions private: string name[]; }; Test() { //heres where i want to declare the size of the array } Is this possible? ...

Accessing member variables through boost lambda placeholder

I'm trying to print the second member variable of all items in an stl map using a lambda expression map<int, int> theMap; for_each(theMap.begin(), theMap.end(), cout << bind(&pair<int, int>::second, _1) << constant(" ")); but this is not compiling. I essentially want to de-reference the placeholder. Any idea what I'm missing...

Using input to call a member function

Is it possible to use Input to call a member function? void one() { } cout << "enter input:" << endl; cin >> input; //where input is "one" instance.input() ...

C++ typename of member variable

hello everybody Is it possible to get typename of a member variable? For example: struct C { int value ; }; typedef typeof(C::value) type; // something like that? Thanks ...

c++ defining a static member of a template class with type inner class pointer

I have a template class like here (in a header) with a inner class and a static member of type pointer to inner class template <class t> class outer { class inner { int a; }; static inner *m; }; template <class t> outer <t>::inner *outer <t>::m; when i want to define that static member i says "error: expected con...

How do I use custom member properties for people on my .NET website

I am trying to make an asp.net website using Visual web dev and C# that accesses data in an SQL database. For my site, I need to be able to save and access additional user properties such as age and gender. I have been playing around with the built in .NET Login tools but I don't understand how to keep track of the additional propertie...

c++ templates: problem with member specialization

I am attempting to create a template "AutoClass" that create an arbitrary class with an arbitrary set of members, such as: AutoClass<int,int,double,double> a; a.set(1,1); a.set(0,2); a.set(3,99.7); std::cout << "Hello world! " << a.get(0) << " " << a.get(1) << " " << a.get(3) << std::endl; By now I have an AutoClass with a working "se...

Why protected superclass member cannot be accessed in a subclass function when passed as an argument?

I get a compile error, which I'm slightly confused about. This is on VS2003. error C2248: 'A::y' : cannot access protected member declared in class 'A' class A { public: A() : x(0), y(0) {} protected: int x; int y; }; class B : public A { public: B() : A(), z(0) {} B(const A& item) : A(), z(1) { x = item.y;} private: int z...

C# binarysearch a list<T> by a member of T

I have a baseclass Event with a DateTime member TimeStamp. Lots of other event-classes will derive from this. I want to be able to search a list of events fast, so I'd like to use a binary search. (The list-data is sorted on timestamp, but there might be duplicate timestamps for events that occurred simultaneously) So I started out wr...

In actionscript, why is my static class member variable not the same when accessed from different parts of my app?

I have an actionscript class with a static member variable defined. public class A { public static var x:int; } When I try to access it from different parts in my code I don't get the same value in each spot. A.x I am accessing the variable in different modules that are loaded, so they are all in their own separate .swf file....

How to assign custom property to jQuery object?

I need to assign a custom property to a jQuery object. Here is the object: var object = $("<div id='item'></div>"); I need object to have a custom data member. How can I add this? ...

Static Member Variables of the Same Class in C++

I'm trying to create a class which contains a static pointer to an instance of itself. Here's an example: A.h: #include <iostream> #ifndef _A_H #define _A_H class A { static A * a; }; A * a = NULL; #endif However, when I include A.h in another file, such as: #include "A.h" class B { }; I get the following error: ld: dupli...