reference

C++ Passing a dynamicly allocated 2D array by reference

六眼飞鱼酱① 提交于 2020-01-03 20:17:29
问题 This question builds off of a previously asked question: Pass by reference multidimensional array with known size I have been trying to figure out how to get my functions to play nicely with 2d array references. A simplified version of my code is: unsigned int ** initialize_BMP_array(int height, int width) { unsigned int ** bmparray; bmparray = (unsigned int **)malloc(height * sizeof(unsigned int *)); for (int i = 0; i < height; i++) { bmparray[i] = (unsigned int *)malloc(width * sizeof

How can I use array-references inside arrays in PHP?

风流意气都作罢 提交于 2020-01-03 19:37:15
问题 I want to be able to do the following: $normal_array = array(); $array_of_arrayrefs = array( &$normal_array ); // Here I want to access the $normal_array reference **as a reference**, // but that doesn't work obviously. How to do it? end( $array_of_arrayrefs )["one"] = 1; // choking on this one print $normal_array["one"]; // should output 1 Regards /R 回答1: end() doesn't return a reference of the last value, but rather the last value itself. Here is a workaround: $normal_array = array();

NHibernate - join without mapping

丶灬走出姿态 提交于 2020-01-03 19:18:36
问题 Is it possible to join two classes without specified mapping between them (using Criteria API)? I must join two classes and retrieve data from both but I can't mapping them. I know only foreign key SomeID in the first class and primary key ID in second. How to create Criteria to join them? Is it possible without mapping? Please, help, I'm really need it but I'm stuck. :/ PS I know 'any' mapping but I have 10 fields like SomeID. Creating any mappings for 10 fields only for creating joins is

NHibernate - join without mapping

匆匆过客 提交于 2020-01-03 19:18:32
问题 Is it possible to join two classes without specified mapping between them (using Criteria API)? I must join two classes and retrieve data from both but I can't mapping them. I know only foreign key SomeID in the first class and primary key ID in second. How to create Criteria to join them? Is it possible without mapping? Please, help, I'm really need it but I'm stuck. :/ PS I know 'any' mapping but I have 10 fields like SomeID. Creating any mappings for 10 fields only for creating joins is

Why VS2012 project with referenced assembly can't target 4.0 automatically

纵饮孤独 提交于 2020-01-03 17:35:53
问题 In a Visual Studio 2012 C# console application, I downgrade ".NET Framework Target" from 4.5 to 4.0. Win 7 Pro with both Frameworks installed. I then reference an assembly, which, through warnings complains the following: The primary reference "System.Threading.Tasks.Dataflow, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=4.0.0.0,

How to check if variable was passed by reference in PHP

可紊 提交于 2020-01-03 17:17:30
问题 Straightforward: I want to write some code which tells if a variable was passed by reference or not. For example: <?php function isReference($variable) { //return TRUE if &$something was passed //return FALSE if $something was passed } $text = 'Anything'; $a = isReference(&$text); //return TRUE $b = isReference($test); //return FALSE ?> For those who are curious - why do I need it? Firstly I do not like to leave problems unsolved. Secondly, I am currently enhancing by skills by writing an

Return a reference by a class function and return a whole object in c++?

心已入冬 提交于 2020-01-03 17:15:28
问题 Operator overloading in class CVector: CVector CVector::operator+ (CVector param) { CVector temp; temp.x = x + param.x; temp.y = y + param.y; return (temp); } and in main: CVector a (3,1); CVector b (1,2); CVector c; c = a + b; So an object is passed by value, and then another temp object is being created. I guess b is being passed by value, a is the one calling the + therefore the x and y belong to a and pram.x and param.y to b. temp is returned and the the copy assignment operator delivers

Return a reference by a class function and return a whole object in c++?

放肆的年华 提交于 2020-01-03 17:14:06
问题 Operator overloading in class CVector: CVector CVector::operator+ (CVector param) { CVector temp; temp.x = x + param.x; temp.y = y + param.y; return (temp); } and in main: CVector a (3,1); CVector b (1,2); CVector c; c = a + b; So an object is passed by value, and then another temp object is being created. I guess b is being passed by value, a is the one calling the + therefore the x and y belong to a and pram.x and param.y to b. temp is returned and the the copy assignment operator delivers

Python: Pass by reference and slice assignment

独自空忆成欢 提交于 2020-01-03 16:43:32
问题 In Python, lists are passed by reference to functions, right? If that is so, what's happening here? >>> def f(a): ... print(a) ... a = a[:2] ... print(a) ... >>> b = [1,2,3] >>> f(b) [1, 2, 3] [1, 2] >>> print(b) [1, 2, 3] >>> 回答1: Indeed the objects are passed by reference but a = a[:2] basically creates a new local variable that points to slice of the list. To modify the list object in place you can assign it to its slice(slice assignment). Consider a and b here equivalent to your global b

Can C++ compiler assume a const bool & value will not change?

放肆的年华 提交于 2020-01-03 16:39:36
问题 Can the C++ compiler assume a 'const bool &' value will not change? For example, imagine that I have a class: class test { public: test(const bool &state) : _test(state) { } void doSomething() { if (_test) { doMore(); } } void doMore(); private: const bool &_test; }; And I use it as follows: void example() { bool myState = true; test myTest(myState); while (someTest()) { myTest.doSomething(); myState = anotherTest(); } } Is it allowed by the standard for the compiler to assume _test's value