member

Accessing member variables through boost lambda placeholder

谁说我不能喝 提交于 2019-12-13 12:09:10
问题 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 here? Thanks in advance! 回答1: std::map will add const to its key; this is to prevent messing up the ordering. Your pair should be: std::pair<const int, int> Like

Can I transform an object and access the private data members in C++?

ぐ巨炮叔叔 提交于 2019-12-13 12:04:37
问题 I want to access a private data member in a class. There is no member function in the class to access the private data member. It is private. I want to take the class and some how crack it open. One method was to copy the declaration of the class, make the private member public and call the new class class something_else. Then I do a reinterpret cast and copy the original object. This works. But I want something more elegant ... or perhaps generic ... or just another way. What options are

Referencing to a pointer member in a different class

戏子无情 提交于 2019-12-13 09:46:23
问题 I have a Note and a Track class which both *generator member. When I create new Note objects I want to link the generator member of Note to that of Track but I can't figure out how to do this. #include <iostream> using namespace std; class Generator { public: virtual float getSample(int sample)=0; }; class Note { public: Generator *generator; // THIS IS WHAT IS CAUSING ME TROUBLE Note(Generator *aGen){ generator = aGen; } }; class Synth : public Generator{ public: virtual float getSample(int

C++ Call member function from other class

情到浓时终转凉″ 提交于 2019-12-13 08:54:53
问题 I have this code. Just 2 small classes and main. ----------MAIN.CPP---------- #include <iostream> #include "Calendar.h" #include "Transaction.h" using namespace std; int main() { cout << "Inicializuji" << endl; double Time = 0.0; Calendar calendar; cout << "Vkladam uvodni udalost" << endl; calendar.calendarPush(Time, 1, &Transaction::event1); calendar.calendarRun(); } ----------CALENDAR.H---------- #include <iostream> #include <queue> using namespace std; class Calendar; class Transaction;

Can the SQlMembershipProvider be used with umbraco

被刻印的时光 ゝ 提交于 2019-12-13 06:41:16
问题 Does anybody have an examples of this, from what I've read umbraco kicks up a bit of a stink but I can't find any examples 回答1: You can do it for members in front-end, but not users in the back-end. doing so is very easy, just change the providers section in web.config. I have used umbraco with SQlMembershipProvider, as well as custom membership providers I had implemented my self. 回答2: Yes, you absolutely can use the SqlMembershipProvider with Umbraco. First, you must add your connection

How to get a “simple” function pointer from a member function

冷暖自知 提交于 2019-12-13 05:03:31
问题 I'm having a problem with function pointers and nothing I found on the net helped me to solve this problem. I have a function from a C API which take a pointer of a void function : extern int APIFunction(int, void (*func)(int)); I have a class with the function I would like to put when I call the API function. class MyClass { public: void myFunction(int status, otherAPi arguments...); }; Then, I created a pointer to my member function and created a new instance of my class typedef void

iterator Overload Member Selection vs Indirection Operator

北慕城南 提交于 2019-12-13 04:43:56
问题 So in the interest of creating a Minimal. Complete, Verifiable Example I have created a toy iterator here (I know it's not perfect, it's just for the purposes of asking a question): class foo : public iterator<input_iterator_tag, string> { string _foo; static const size_t _size = 13; public: const string& operator*() { return _foo; } const foo& operator++() { _foo += '*'; return *this; } const foo operator++(int) { auto result = *this; _foo += '*'; return result; } bool operator==(const foo&

What is the proper way to call default constructors?

血红的双手。 提交于 2019-12-13 02:57:17
问题 Lately I have been having difficulties with constructors, and the different attempts from other questions and guides always have some form of segfault waiting for me at runtime (making compiling 80% of my time spent programming). The following example shows the basic idea on what I am trying to accomplish: struct Coord3{ float x, y, z; Coord3() {x=0;y=0;z=0;};///Is this Correct? }; struct Stat{ int Str,Dex,Int; Stat(){Str=0;Dex=0;Int=0;}; }; struct Item{ Stat myStats; Item(){...}; }; class

'Application' is not a member of 'My'

本秂侑毒 提交于 2019-12-12 21:25:38
问题 I'm trying to add a Splash Screen to my form, but I'm getting the error - 'Application' is not a member of 'My'. I've done some research and came across two possible solutions, but neither of them have worked for me. Splash Screen Error "'Application' is not a member of 'My'." The answer here suggests ticking the 'Enable Application Framework' option in the Project settings, but that option is greyed out. The 'My' Namespace in a VB.NET Application is Missing Members. This answer suggests that

Conditional Member Functions

佐手、 提交于 2019-12-12 14:54:48
问题 What's the recommendation regarding conditionally defining member functions in a C++ class? (The question is centered around limiting the external exposure of some classes in a DLL - specifically when those classes are passed in as a parameter). Obviously this isn't something you want to do to data members, but functions should be OK shouldn't they? For example: class A { public: void func1(); #ifdef _CONDITION_ void func2(B b); #endif }; Edited: Added public modifier to avoid example