member

C++ Static Const Member Variable Usage

♀尐吖头ヾ 提交于 2019-12-03 09:11:26
问题 Say that I have a class that requires a few constants to function. Several member functions require use of these constants. Use of #define is frowned upon since it can cause collisions. The constants are hex patterns of 8 or 16 bits and are stored as uint8_t or uint16_t. These constants also don't change from instance to instance of the class, and therefore memory (albeit very little memory) can be saved by having only one copy of the constants. Is there anything improper, or perhaps of

Why does a non-static field not act as a GC root?

喜欢而已 提交于 2019-12-03 08:22:48
As I know static fields (along with Threads, local variables and method arguments, JNI references) act as GC roots. I cannot provide a link that would confirm this, but I have read a lot of articles on it. Why can't a non-static field act as a GC root? First off, we need to be sure we're on the same page as to what a tracing garbage collection algorithm does in its mark phase. At any given moment, a tracing GC has a number of objects that are known to be alive, in the sense that they are reachable by the running program as it stands right now. The main step of mark phrase involves following

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

强颜欢笑 提交于 2019-12-03 07:46:24
问题 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) { return 0; } int main() { typedef BOOST_TYPEOF(foo) foo_type;; typedef boost::function_traits<foo_type> function_traits; cout << typeid(foo_type).name() << endl; cout <<

About sizeof of a class member function pointer [duplicate]

可紊 提交于 2019-12-03 06:13:53
This question already has answers here : Pointers to members representations (2 answers) Let's say we have a class A class A; and these typedefs typedef void (A::*a_func_ptr)(void); typedef void (*func_ptr)(void); My question is why sizeof(a_func_ptr) returns 16, while sizeof(func_ptr) returns 4 (as for any pointer on x86 system)? For instance int main(int argc, char *argv[]) { int a = sizeof(a_func_ptr); int b = sizeof(func_ptr); } Nawaz My question is why sizeof(a_func_ptr) returns 16, while sizeof(func_ptr) returns 4 (as for any pointer on x86 system)? Because pointer-to-members are

MDX Calculated member filter by dimension attribute

£可爱£侵袭症+ 提交于 2019-12-03 05:59:03
问题 I want to create a calculated member and filter it by dimension. This is WORKING example: ( [Policy].[Policy Status].&[Void], [Policy].[Tran Type].&[Renewal], [Measures].[FK Policy Distinct Count] ) But if I want to filter it like this ( [Policy].[Policy Status].&[Void], [Policy].[Policy Status].&[Policy], [Measures].[FK Policy Distinct Count] ) Than it's NOT working. It says that same hierarchy is showing multiple times in the tuple. Another thing is, how to exclude rows? Here's the idea...

C++ Member Variables

我的梦境 提交于 2019-12-03 05:01:38
Consider the following class: class A { A(); int number; void setNumber(int number); }; You could implement 'setNumber' in 3 ways: Method 1 : Use the 'this' pointer. void A::setNumber(int number) { this->number = number; } Method 2 : Use the scope resolution operator. void A::setNumber(int number) { A::number = number; } Method 3 : Instead, denote all member variables with 'm' or '_' (this is my preferred method). void A::setNumber(int number) { mNumber = number; } Is this just personal preference, or is there a benefit to choosing a particular method? Kerr This is mostly a personal preference

PowerShell how to add something on parsed JSON?

社会主义新天地 提交于 2019-12-03 04:52:49
I want to add something in my parsed JSON using PowerShell. My code: function ConvertFromJson([string]$file) { [System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") $jsoncontent = Get-Content $file $jsonobj = New-Object System.Web.Script.Serialization.JavaScriptSerializer $global:json = $jsonobj.DeserializeObject($jsoncontent) } My JSON: { "BlockA": { "BlockB": { "name": "BlockB", "value": "Value_B" }, } I want make BlockC like this: { "BlockA": { "BlockB": { "name": "BlockB", "value": "Value_B" }, "BlockC": { "name": "BlockC", "value": "Value_C" }, } I tried $json.BlockA

Constructor for '' must explicitly initialize the reference member ''

≡放荡痞女 提交于 2019-12-03 04:31:11
I have this class class CamFeed { public: // constructor CamFeed(ofVideoGrabber &cam); ofVideoGrabber &cam; }; And this constructor: CamFeed::CamFeed(ofVideoGrabber &cam) { this->cam = cam; } I get this error on the constructor: Constructor for '' must explicitly initialize the reference member '' What is a good way to get around this? You need to use the constructor initializer list: CamFeed::CamFeed(ofVideoGrabber& cam) : cam(cam) {} This is because references must refer to something and therefore cannot be default constructed. Once you are in the constructor body, all your data members have

Immutable Object with ArrayList member variable - why can this variable be changed?

半世苍凉 提交于 2019-12-03 02:25:48
问题 I have got one class with various member variables. There is a constructor and there are getter-methods, but no setter-methods. In fact, this object should be immutable. public class Example { private ArrayList<String> list; } Now I noticed the following: when I get the variable list with a getter-method, I can add new values and so on - I can change the ArrayList . When I call the next time get() for this variable, the changed ArrayList is returned. How can this be? I didn't set it again, I

Difference between these arrays as member variable of view controller

三世轮回 提交于 2019-12-03 01:21:41
问题 I would like to have an array as a member of my table view controller. The array will be a data source. What are the differences or advantages/disadvantages the following ways of having a member variable array. class BinViewController: UITableViewController, WKNavigationDelegate { var peopleArray1 = [String]() var peopleArray2: [String] = [] var peopleArray3: [String]! var peopleArray4: [String]? 回答1: These two basically do the same thing: var peopleArray1 = [String]() var peopleArray2: