FAQ Database Discussion Community


SomeClass &a = *new SomeClass(…)

c++,reference
I have come across a construct that I have not seen before and am wondering what the purpose of it is: { SomeClass &a = *new SomeClass(...); a.someFunc(); } If my understanding is correct, a is a reference to SomeClass, and is created via new. What purpose does this serve?...

Quickest way to evaluate a variable in TCL

reference,tcl,expect,evaluation
I have a variable myref set to: set myref {$expect_out(buffer)} What is the quickest way to get the $expect_out(buffer) into myval? set myval [HOWTOEVAL $myref] ...

Referencing a numpy arrray without creating an expensive copy

python,arrays,numpy,reference,slice
Let's say that I have a function that requires that NumPy ndarray with 2 axes, e.g., a data matrix of rows and columns. If a "column" is sliced from such an array, this function should also work, thus it should do some internal X[:, np.newaxis] for convenience. However, I don't...

Returning a reference from a pointer

c++,pointers,c++11,reference,singleton
I have this class in singleton.h: class SingletonSample { public: static SingletonSample& Instance(); int DoSomething() const; private: SingletonSample(); ~SingletonSample(); SingletonSample(const SingletonSample&) = delete; SingletonSample& operator=(const SingletonSample&) = delete; static SingletonSample* _instance; } And I have this implementation in singleton.cpp: SingletonSample::SingletonSample() {} SingletonSample::~SingletonSample() {} SingletonSample& SingletonSample::Instance() { if(!_instance) _instance = new...

return reference of static member variable c++

c++,reference,static
Is there any problem to return a reference of a static member variable? (Reference to avoid copy cost) Vector accepts 4 parameters(x,y,z,w); .h class MyClass { private: static const Vector POS; } .cpp const Vector MyClass::POS(100,300,0,0); const Vector& MyClass::GetVector() { return POS; } ...

c++ 2 ref classes should have acess to one same object of a other class

c++,windows,reference,system,command-line-interface
I have 2 classes let's say class a und b. And even a thrid class c. class a and b should have acess to the functions of the same object of class c. I want to have a member like a reference. So the argument in the construktor of class...

How to declare a reference to a empty stack in OCaml?

reference,ocaml,imperative-programming
perhaps I am being stupid here, so the more general question I want to ask is that how to declare a reference to a empty value of certain type in OCaml. Usually I declare a reference to a custom defined empty value, for example if I have a type type...

C# - Getting List reference index

linq,list,object,reference,compare
I have a List> List<List<Byte>> bytes = new List<List<Byte>>() { new List<Byte> {1, 1, 2, 3, 4}, // index 0 is original new List<Byte> {0, 0, 2, 4, 1}, new List<Byte> {1, 2, 2, 1, 1}, new List<Byte> {1, 0, 2, 2, 2} }; and the first List is original....

Perl return array from multidimensional array

arrays,perl,multidimensional-array,reference,grep
I've got this multidimensional array: @valid_values = (["val00", "val01", "val02"], ["val10", "val11", "val12"]); Via grep I want to check, if a certain value exists within the first array of the multidimensional array. I've tried something like this: if (grep $_ eq $check_value, @valid_values[0]) {print "ok\n"} This doesn't work though. I've...

Passing Complex real and imag by reference

c++,c++11,reference,complex-numbers,rvalue
The Problem: C++11 has made some changes to complex numbers so that real() and imag() can no longer be used and abused like member variables. I have some code that I am converting over that passes real() and imag() to sincosf() by reference. It looks a little like this: sincosf(/*...*/,...

Storing static object reference into a non-static instance variable

c#,reference,static
My goal is to keep static Bitmaps in child classes and use logic in base class with minimal amount of code in child classes. At the moment I've got 2 classes: LEDa, LEDb, that derive from LED. Each of the child classes needs it's own set of static objects (huge...

How to change reference in created import function in R?

r,function,reference
I tried to create a function that allows me to import file quickly, but I could not import it with the name I wanted. The code is as following: g.import<- function(x) { x <<- read.csv(file.choose(), header=TRUE, sep=",") assign('x',x,envir=.GlobalEnv) return(head(x,3)) } g.import(x=a) I will get the imported file named x, but...

Reassigning Object References in Java [duplicate]

java,object,reference
This question already has an answer here: Is Java “pass-by-reference” or “pass-by-value”? 54 answers I just want to clarify something. Why is person1 and person2 still referring to the same object? class Person{ private String name; Person(String newName) { name = newName; } public String getName() { return name;...

Python duplicate a python-igraph

python,reference,duplicates,igraph
I have a python-igraph and need to make two copies of it and change each of the copies without changing the other one. Right now I am doing it like this: copy1 = fullGraph copy2 = fullGraph But it seems that this is not the correct way of doing it...

Visual studio does not exist in the namespace, but reference is added

c#,visual-studio-2012,reference,code-coverage
I am building a custom code coverage app using the Microsoft.VisualStudio.Coverage.Analysis class. I have added the reference to the dll to my solution already and when I start typing the using statement at the top of my class Visual Studio is predicting the correct names, e.g. after typing "Microsoft." "VisualStudio"...

Could not load file or assembly 'Microsoft.SqlServer.Types even with Copy Local

c#,reference
I have an internal report on my web application which when I browse to it locally displays as expected. I am using a rdlc and xsd with a standard apsx web page to render the report. I have now deployed to my staging server and when I try to browse...

Why does my value change when I am not resetting it?

perl,reference
I have the following example exhibiting the problem I'm struggling to resolve. In the toy example, I have an array @actors with two levels. I also have an array of hashes @people which I am using to 'look up' properties of the people in @actors. The output of the program...

returning reference to private vs public member

c++,qt,reference,private,public
I would like to know what could be reasons to provide a public access method returning a reference instead of making the member public. QPoint has methods int& rxand int& ry that let me directly manipulate the coordinates. I guess the implentation looks similar to this: public: int& rx(){return x;}...

Laravel References 2e en 3th level

php,laravel,reference,foreign-key-relationship
I have 3 tables. Table news (hasMany Writers) id name Table Writers (hasMany News and BelongsTo Country) id Name country_id Table Countries (hasMany Writers) id name Now I want to display this in a view: Name(news), Name(Writer), Name(Country) I only can display: Name(news), Name(Writer), country_id How do I display the...

Assign a reference return value to a non-reference variable

c++,reference
class A { ... }; A& getA(); A anA = getA(); What happens exactly on line 3 ? Is the copy constructor of A called, thus creating an object independent from the one returned (by reference) by the function?...

Microsoft Access - Missing Reference to acrobat.tlb

vba,ms-access,reference
I am working with a Microsoft Access database that was mostly completed in Access 2010, and now I am opening it on a new computer that has Access 2013. Upon opening the program, it tells me, "Microsoft Access database or project contains a missing or broken reference to the file...

Conditionally include script for browsers

javascript,jquery,javascript-events,reference,conditional-statements
I have such kind of script code setTimeout(function () { $('.grayscale .inactive img').each(function () { $(this).wrap('<div style="display:inline-block;width:' + this.width + 'px;height:' + this.height + 'px;">').clone().addClass('gotcolors').css({ 'position': 'absolute', 'opacity': 0 }).insertBefore(this); this.src = grayscale(this.src); }).animate({opacity: 1}, 500); $(".grayscale li").hover(function () { $(this).find('.gotcolors').stop().animate({opacity: 1}, 200); }, function () {...

Using NON static class Methods Without reference

java,object,methods,reference,static
I'm new to Java. I know the concept of static and non static method. I'm wondering if it's possible to use non static methods of a class without having to create a reference to it. Like for example, for my program I'm working with Date objects, and I need to...

Every include should refer to other instance

jsf,jsf-2,reference,uiinclude
I include a part of the XHTML page to my Web Application. This part can be included multiple times. And that's the problem! Because every include refers to the same java object. That means that every element has the same value. But I want for each include a new Java...

(Dangling?) Reference returned from function does not “work”

c++,pointers,reference,unique-ptr
I followed V. Romeo's Tutorial on entity management (on GitHub & Youtube). I then tried to rewrite the classes CEntity, CComponent and for testing CPosition(mostly from memory from Romeo's video/code). The problem i encounter is that, in my main i create a CEntity on the stack & add a component....

TCL access array by reference/name

arrays,reference,tcl
Let's say I have a regular variable that contains the name of an existing array. array set myarr { key_1 val_2 key_2 val_2 } set myvar myarr I can found nowhere how I can iterate over myarr from myvar!...

Drop reference when only a single link to it

c#,reference,garbage-collection
I am storing a list of delegates in a dictionary, and then invoking them when required, problem is, when UI is no longer visible, the references to the delegates still exist, and when the UI shows up again, its a new instance, adds new references in addition to the old...

Sublists in a 2D List, Referencing

java,reference,sublist
I have a 2D List of objects. I'm trying to access a list and replace it with a sublist of itself. I made up a simple example below, I want to replace dList.get(0) with dList.get(0).subList(1,3). I use a reference variable, which updates the values in the original list, but the...

Why can a raw type reference refer to a generic instance? [duplicate]

java,generics,reference,generic-collections,raw-types
This question already has an answer here: Is List<Dog> a subclass of List<Animal>? Why aren't Java's generics implicitly polymorphic? 8 answers Please help understand why Map map1 = new HashMap<String,String>(); // This compiles Map<Object,Object> map2 = new HashMap<String,String>(); // This does not. As per my understanding Map map1 is...

Why a slice []struct doesn't behave same as []builtin?

go,reference
The slices are references to the underlying array. This makes sense and seems to work on builtin/primitive types but why is not working on structs? I assume that even if I update a struct field the reference/address is still the same. package main import "fmt" type My struct { Name...

How to get API documentation to be shown inside Eclipse Help window?

java,eclipse,reference,documentation,javadoc
I've downloaded jdk-8u45-docs-all.zip from here, wrote it's link to my jdk's javadoc location in Eclipse. Everything works just well, when I hover over something the tooltip appears, when I press shift+F2 offline API documentation opens in browser. The only thing that doesn't work - When I write some search query...

Code::blocks complaining about type of parameter

c++,reference,compiler-errors,codeblocks
I am building a 3D Game Engine. I have build many in other languages, but finally decided to reap the speed benefits of C++ (despite not knowing it particularly well). I have a class called EngineOptions that I use to store information about how the engine is to be initialized....

Why does this code in java print a reference instead the result of invoking the method?

java,arrays,methods,reference,boolean
I am supposed to write a method that accepts 3 2-D arrays of This method should determine whether one of the matrices is the result of matrix addition of the other two. public class Matrix { public static void main(String[]args){ int [][] a = {{5,2,3},{4,1,6},{0,7,2}}; int [][] b = {{1,2,3},{4,5,6},{0,1,2}};...

Passing an array by reference to thread

c++,multithreading,templates,c++11,reference
I have an array that needs to be passed to multiple threads to be worked on. The array size is know at compile time. Here is a working reduction to the essentials where the function is called directly, not via a thread: #include <thread> template <class TYPE> void function(TYPE& data,...

How can I tell PHPStorm to find references to rewritten URLS?

reference,phpstorm,file-rename
I wanted to rename one of my files, mypage.php into myprofile.php, but PHPStorm does not find any file references. In the code, mypage.php is referenced without the file extension. For example: <a href='../user/mypage/'> So it has to look for mypage, not mypage.php and rename it myprofile, without file extension. How...

Non-static method reference?

java,methods,reference,non-static
A little side project I've been doing for fun involves subtracting the current date from a future date given by the user to return the days between them. public int getDaysBetween(int date2) { //Subtract current date from future date (date2), leaving the number of days between them int getDaysBetween =...

perl reference hash slice

perl,reference
I have below hash: my %gilligan_info = ( name => 'Gilligan', hat => 'white', shirt => 'Red', position => 'First Mate', ); my %skipper_info = ( name => 'Skipper', hat => 'Black', shirt => 'Blue', position => 'Captain' ); I have a array of hashes: my @crew = (\%gilligan_info, \%skipper_info);...

Troubles with reference variables/pointers an class members [C++]

c++,class,reference
I've been working on a project and have quite a few classes, a few of which look like this: class A { // stuff; }; class B { A& test; public: B(A& _test) : test(_test) {}; void doStuff(); }; class C { A foo; B bar(foo); void exp() { bar.doStuff();...

Method works if called from one Class but not from another

java,methods,reference
I am new to Java. I am working on a GUI for Serial Communication between a PC and a Microcontroller. I am using the RXTX Library and it works. As i want to be able to modify the GUI from another Classes, i built the Programm as follows: 1: Main...

Can't use an undefined value as a symbol reference in perl

perl,reference
I'm getting an error message Can't use an undefined value as a symbol reference. I can't work out what I'm doing wrong based on other answers to this question: use strict; use warnings; print "Enter sequences to print (six1 = 0 eya1 = 1 six1-eya1 = 2): "; chomp($seqs_to_print =...

Object passed by reference will not exist. Swift

ios,swift,reference,pass-by-reference
I have an array. var array:[customType] = [] // pseudo code func Generate_New_Array(){ //initialization of generatedNewArray array = generatedNewArray for (index,element) in array{ async_process({ Update_Data_From_Web(&array[index]) }) } }) } func Update_Data_From_Web(inout object:customType){ download_process{ object = downloadedData } } The question is , what will should I do if I call...

C++ - Why does 2 local references to the same object stay in sync?

c++,pointers,syntax,reference,variable-assignment
I would like to understand what's going on here. Obviously, there's some aspect of references or assignment operators that I am not getting right. Objective: Within a function, I want to work with 2 local reference variables to various elements of the same list: one is the iterated over and...

callback function using an array, does the function use the updated array?

javascript,reference
I am debugging my code and I can't seem to figure out what's wrong. Therefore I'm just double checking my understanding of javascript. If I have the following: var myArray = [] $(document).on('mousemove', function(e){ if (myArray.length > 0) { //do something } else { //do other thing } }); If...

Would it be more efficient to pass a variable to a function by reference than to make a function to return a variable?

c++,reference
So this seems like a fairly simple question, but I haven't been able to find an answer to it anywhere online. The reason I'm assuming a function which returns a variable is less efficient than a function which takes a variable and changes it is because I think the first...

Github and Nuget packages

c#,git,github,reference,nuget
I am attempting to contribute to a project on Github (First time). I added a new Project to the solution and added NUnit and AutoFixture (via Nuget), now when I clone that repo it's missing all of the references to NUnit and AutoFixture. Now when I did a pull request...

Is a Java class variable a reference to a class object?

java,class,object,reference
I know such question has been asked before but I couldn't find a satisfactory answer. Assume a java class : class Foo{ public int k; Foo(int a){ k=a; } } class My{ public static void main(String args[]){ Foo obj = new Foo(5);//1 obj=new Foo(8); //2 } } I want to...

Passing const references to functions

c++,reference,const
I was watching a video and saw this code: class Dog { public: Dog() : age(3), name("dummy") {} void setAge(const int &a) { age = a; } private: int age; std::string name; }; I was curious about the function signature for setAge because I've never used const as a function...

Keeping track of references in Java

java,multithreading,reference
In Java, is there any way to tell whether or not references are being maintained to an object in other threads (or generally)? Consider the following class: public class ResourcePool<TYPE> { private final Queue<Object> emptyLocks = new LinkedBlockingQueue<>(); private final Queue<TYPE> available = new LinkedBlockingQueue<>(); private final Queue<TYPE> claimed =...

using the 'Match' function in Exel to return a cell address

excel,reference,match,cell,formula
I have a list of numbers in a table that I would like to search for and bring back the cell reference of where that number resides. For example the data looks like: A B C D 1 1 2 3 4 ok it doesn't come out very well as...

List of object references in python

python,list,reference
I'm aware that this question has already been asked here in one form or another, but none of the answers address the behaviour I'm seeing. I'm given to understand that a list of objects should only hold references to those objects. What I observe seems to contract this: class Foo(object):...

Access to reference in member variable discards constness

c++,c++11,reference,compiler-errors,const
I made a wrapper around an object in my code that should modify accesses to the object. I choose to use an object here for testing instead of a functor that would have the same functionality. Basically: The wrapper receives a reference to the object and forwards all indexed accesses...

Discussion about std::vector and standard array

c++,arrays,pointers,vector,reference
Discussion about std::vector and standard array Say if we have following code: void myclass::loadArray(void *outData) void myclass::loadVector(void *outData) void myclass::func () { //here we have a vector std::vector<int> myVector; myVector.resize(10) // here we have an array int myArray[10]; here I wonder what will be the differences between following implementations //1:...

Method can not initialize value c++

c++,reference,bellman-ford
Firstly I initialize value in constructor in Ford Bellman claas FordBellman::FordBellman() { this->vertexCount=0; this->vertexFirst=0; this->edgeCount=0; this->wage=0; this->matrix=0; this->distance=0; this->predecessor=0; } next I have reference in argument of initialize method in FordBellman void FordBellman::initialize(const AdjacencyMatrix &am) { this->vertexCount=am.getVertexCount(); this->vertexFirst=am.getVertexFirst(); this->edgeCount=am.getEdgeCount(); this->wage=am.getWage();...

passing arguments via reference and pointer C++

c++,function,pointers,reference
I am looking at a code snippet and I have this sequence. class MyVariable { .... CustomType z; .... } A.cpp calling a function f ( & myVariable) In an included file I do have this : B.h void f ( MyVariable * myVariable); B.cpp f( MyVariable * myVariable){ CustomType...

Passing varriables by reference

c#,reference
If I have this class: public class Foo { Boo a; public Foo (ref Boo b) { a=b; } } Is a going to be a reference to b, or a is going to copy the value which ref b points to ? If it copies the value, how can...

Writing C++ API - how to keep external references to API internal objects?

c++,vector,reference,typedef,encapsulation
So I'm writing an API in C++ to be used in another GUI application I'll be writing. The API will allow the user to create instances of "MyObject" and modify the properties of that object, but the object itself will not be exposed to the client, only an ID to...

MongoDB query show all value in array property when reference database

database,mongodb,reference
I cannot show all`, if some value are in array property in mongo document. For example, I have some collection users, and such document: This is collection friend 'list': [ { '_id': '123', 'name':'Charlie', 'age':50, }, { '_id': '234', 'name':'Micheal', 'age':32, }, { '_id': '345', 'name':'Alice', 'age':45, } ] This...

Referencing properties in mongoose

node.js,mongodb,properties,reference,family-tree
I make some file.js like this: File Children.js var mongoose = require('mongoose'); var ChildrentSchema = new mongoose.Schema ({ name: String }); module.exports = mongoose.model("Childrent", ChildrentSchema);` File Dad.js var mongoose = require('mongoose'); var DadSchema = new mongoose.Schema ({ name: String, child: { type: mongoose.Schema.Types.ObjectId, ref: 'Childrent' } }); module.exports = mongoose.model("Dad",...

create a reference to an array in Nim

arrays,pointers,reference,nim
var b: array[5, int] type ArrRef = ref array[5, int] var c : ArrRef echo repr(c) # nil c = addr b # doesn't compile, says type is Array constructor, expected reference In Nim, how can I pass references to arrays instead of passing by value? See the above code...

error: use of overloaded operator '*' is ambiguous

c++,pointers,vector,reference
When I try to compile this source in c++: void ParticleSystem::setState(std::vector<Vec2f>& statesVector) { std::vector<Vec2f> pState(2); for (int i = 0; i < 2*np; i += 2) { pState[0] = *statesVector[i]; pState[1] = *(statesVector[i+1]); (*particles[i/2]).setState(pState); } } I get the following error: ParticleSystem.cpp:110:15: error: use of overloaded operator '*' is ambiguous...

Why can't I return this vector of vectors?

c++,vector,reference,return
I have a class that declares a vector of vectors of type char as the following and contains a method to read half of it and return the resulting vector. class Mapa { private: vector<vector<char> > vec; public: //Constructor Mapa():vec(0,vector<char>(0)){}; Mapa(int row, int col):vec(row, vector<char>(col)){}; virtual ~Mapa(){}; } const Mapa&...

Why can't a function change its argument object's address/reference value?

c++,reference,parameter-passing,pass-by-reference
I learned that in Java and C, you can assign a pointer, pass the pointer to a method, follow the pointer in the method and change the data that was pointed to. However, you cannot change where that pointer points. I thought I could see a different behavior in C++...

System.Windows.Interactivity must be referenced in the main project

c#,wpf,dll,reference
So I have a WPF project and my interface in a different project than the main one. I went to reference System.Windows.Interactivity, but it would not work. Not until I added it as a reference to the main project as well... This is the first time this has ever happened...

reference data class member visitor pattern

c++,design-patterns,reference
I have a container class that has a plain old datatype called DataStore. This data store will be passed to visitor.They share a single copy since any updated performed by the container are to be seen by visitor. class xyz { //Plain Old Datatype typedef struct DataStore { //add any...

Function returns the same value instead of unique values [duplicate]

c#,memory,random,reference
This question already has an answer here: Random number generator only generating one random number 7 answers I found this example on sof. When I use it the code works as designed when it is a singular call. If I make multiple calls to GiveMeaNumber, it returns the same...

Java Pass-by-reference not working?

java,variables,reference,pass-by-reference
I'm trying to make this little game in Java but I seem to have stumbled upon a variable reference problem. My Entity class, which Player extends from, keeps a variable of type Dimension. This Dimension gets set via the constructor of the Entity class like so: protected Dimension dimension; public...

Interfaces are not passed by reference

c#,asp.net,pointers,reference
I need to change at runtime the implementation of an interface. This interface is referenced by many classes. Here is my test case, which is not working as i was expecting. (changing the reference of the interface doesn't seems to update in all the places where its used) Here is...

Backslash before a subroutine call

perl,reference,subroutine
As I was understanding the difference between [] and \ in references,I used both on subroutine the former was fine but when I tried later I thought it should give error but the below program in perl #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @b; for my $i (...

Using a stored integer as a cell reference

excel,excel-vba,reference
Dim x As Integer Dim y As Integer For y = 3 To 3 For x = 600 To 1 Step -1 If Cells(x, y).Value = "CD COUNT" Then Cells(x, y).EntireRow.Select Selection.EntireRow.Hidden = True End if If Cells(x, y).Value = "CD Sector Average" Then Cells(x, y).EntireRow.Select Selection.Insert Shift:=xlDown Cells(x +...

reference a cell from another worksheet using a variable

excel,vba,excel-vba,variables,reference
I'm trying to refer to another worksheet (BASE tab) in the same workbook. I run the code below inside a couple of loops where x and y increment based on certain conditions. I've messed around with the code but I haven't had any luck. This is what I have so...

What is the difference between * and & in function parameters?

c,pointers,parameters,reference,dereference
I have seen something in this form: void function( A_struct &var ) { var.field0 = 0; // ... } Since there is & before var, I thought that var is a pointer. But in the body, instead of writing var->field0, var.field0 is written. So, my questions are: Isn't var a...

Python: how to reference values in a def

python,reference,return
As a very basic example of what I want to do, I want to update the values 1 and 2, after running them through the example method. Like how you would use ref for Java. def example(value1, value2): value1 += 2 value2 += 4 value1 = 0 value2 = 0...

Why does this program compile fine in C++14 but not in a C++11 compiler?

c++,c++11,reference,c++14,list-initialization
I recently tested the simple following program on an online compiler. See live demo here. It compiles fine & gives the expected output but when I tested it on Dev C++ IDE it fails during the compilation. Here is my program: #include <iostream> class Test { int s=9; public: int...

How to check if a linked list is a palindrome or not in Java?

java,reference,linked-list,parameter-passing,value
I wrote a code to check if a singly linked list is a palindrome. And I made two steps: 1st. reverse the original linked list. 2nd. Check if the original and reversed linked list have the same element. public static Boolean isPalindrome(Node input){ Node reversed= reverse(input); while (input!=null){ if(input.item!=reversed.item) return...

Private variable cannot reference to another method in the same class

java,variables,reference
Im new to Java and today i have a problem with my code when I trying to do ActionListener My java class look like here: public class exam{ private void createForm(){ ... JButton jbtn = new JButton("OK"); jbtn.addActionListener((ActionListener) this); ... } public static void main(String[] args){ exam ex = new...

AngularJS - ReferenceError: $ is not defined

javascript,angularjs,canvas,reference
I'm getting the following error when I try to do this var fbcanvas = $('#fbcanvas'); This is the error I got ReferenceError: $ is not defined This is my JS code var feedbackModule = angular.module('feedbackModule', [ 'ui.bootstrap', 'dialogs' ]); feedbackModule.controller('feedbackDialog', function($scope, $rootScope, $timeout, $dialogs) { $scope.confirmed = 'You have yet...

Use code from repository that has no setup.py

python,reference,workflow,setup.py
Is there a best practice for how to use code from a python github repository that is missing its setup.py file? Since I cannot reference it through my own requirements.txt, may I just copy the code into one of my own files? Specifically, I want to use the function tile_raster_images(...)...

Watching a variable in python?

python,reference
In C++, I could imagine constructing with a reference to a counter ( see below ), and then a function would just dereference the address to get a value. Is something similar possible in python? Something like: import time class Count_Watcher: def __init__( self, to_watch ): self.to_watch = to_watch sleep_watch()...

Raycast to get gameobject being hit to run script and function on gameobject

c#,unity3d,reference,raycasting
I'm in the process of getting multiple enemies to work in my game for my college project. I have a player with a ShootGun script which raycasts the gun and detects whether or not the object hit is one of the enemy colliders (tagged with Enemy_Head, _Torso and _Limb). If...

The type 'System.Runtime.InteropServices.SafeHandle' exists in both 'System.Runtime.InteropServices.dll' and 'System.Runtime.Handles.dll'

c#,dll,reference,compiler-errors,interop
I'm currently porting a Windows 8.1 app to a Windows 10 UAP app which uses interop to communicate between C++ and C# and I'm having the following error popping up : $(ProjectName).Interop.g.cs : error CS0433: The type 'System.Runtime.InteropServices.SafeHandle' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5.1\System.Runtime.InteropServices.dll' and 'c:\Program Files (x86)\MSBuild\Microsoft.NetNative\x86\ilc\lib\McgDependencies\System.Runtime.Handles.dll' From...

Swap and Return Char Array from the Function

c++,arrays,reference,char,swap
I know there are many questions related to my this question but still facing problem. I'm using the function to swap array mean when I input ABCD it shoudl return DCBA. Code is below check where is problem. Is there a way to pass second empty array as reference? Swap...

Int& to const int -static vs dynamic-

c++,dynamic,reference,const
class A { public: A(int i = 25) {x = i;y=new int[i];for(int j=0;j<i;j++) y[j]=j;} int& f() const {return x;} int& operator[](int i) const {return y[i];} private: int x,*y; }; int main() { A a(15); cout << a[5]; cout << a.f(); return 0; } When I'm trying to compile the code...

Function with constant reference as input

c++,string,reference
I am trying to make a function that takes a constant reference of a string as input and returns the string after each character of the string is rotated 1 place to the right. Using references and pointers still confuses me and I am not sure how to obtain the...

Im referencing a constant class static variables, but when i do the values somehow change

c#,visual-studio-2013,reference,static
Here is my constant class that i reference from. Below that is the class that is trying to use the reference. Here is the error message im getting. The Type initializer for ConstantClass threw an exception ---> System.OverflowException: Value was either too large or too small for a Decimal. Any...

Understanding the Debug implementation for Vec

reference,rust,dereference
Trying to implement the Debug trait for a custom type I stumbled upon the implementation for Vec<T>. I have difficulties understanding how it works. The implementation goes like this: impl<T: fmt::Debug> fmt::Debug for Vec<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } I understand it...

Java : setting object to null within a method has no effect (Reusing code)

java,algorithm,reference,binary-search-tree
I am trying to write a method to delete a Node from a Binary Search Tree. Here is my method to delete a node. public void delete(int deletionNodeValue) { Node<Integer> nodeToBeDeleted = getNode(deletionNodeValue); if(nodeToBeDeleted == null) return; // No node with such value exists throw an error if(isLeafNode(nodeToBeDeleted)) { nodeToBeDeleted...

How to Find a class in external reference that implements certain interface?

c#,visual-studio-2013,interface,reference
I'm working on a project where I have added an external reference. I have searched through this reference with the object explorer. I have found an interface with a function I would like to use. Now to implement an interface you will need a class which have all the functions...

Why can't I pushback a new element to a list

c++,pointers,reference
I met a problem when I try to pushback a new element to a list. This problem is to write the function implementation of PushBack() according its calling in the main body. So my question is just about the function PushBack(). #include <iostream> class Node{ public: static Node* MakeNode() {...

Return type of list front (C++)

c++,function,reference,linked-list,return-type
So I want to use a list for a part of my program. I'm trying to get acquainted to the library list, so I wrote a quick little program to help myself understand what's going on. It all works properly, but there's one thing I don't understand. According to this:...

C++: creating an instance of an iterator nested class

c++,templates,reference,nested-class
I have a class called OrderedList in a namespace MYLIB. In it I have a nested class called iterator which will be used as an iterator for the OrderedList class. Following is the snippet of my code where I create OrderedList and iterator classes: template<class T> class OrderedList { private:...

Wrong Theme being applied to PreferenceActivity with xml reference

android,xml,reference,themes,android-preferences
I seem to have a problem implementing a theme onto a PreferenceActivity when i am using an XML reference to refer to said theme. I have 3 style.xml´s style.xml style.xml (v16) style.xml (v21) each of these in its appropriate values directory. To apply the theme, i reference it in my...

Adding reference of current record in a one2many relationship

python,reference,openerp-7
import openerp from openerp import netsvc, tools, pooler from openerp.osv import fields, osv from openerp.tools.translate import _ import time import sys import os import string import logging _logger = logging.getLogger(__name__) #_logger.error("my variable : %r", my_var) class reclamation(osv.Model): _name = '_reclamation' _columns = { 'num': fields.char('Numéro'), 'etat': fields.selection([('o','Ouvert'),('f','Fermé')],'Etat'), 'catg': fields.selection([('p','Production'),('s','Sinistre')],'Catégorie'), 'souscatg':...

Parameters to use in a referenced function c++

c++,pointers,reference
I am very confused as to what kind of variables I would put into my function here: names. I am doing a practice problem in a C++ book, because I am learning C++ and am on References and pointers right now, and cannot find a solution. Just for background information,...

C++ - Reference where to put it? [duplicate]

c++,function,reference
This question already has an answer here: Where ampersand “&” can be put when passing argument by reference? 3 answers Hi I have a basic question and sorry if it's a duplicate, but I can't seem to find what I'm looking for with google. I have this function signature:...

Is it possible to define a parameter set and reference it?

reference,swagger,swagger-2.0
I have multiple parameters that I want to reference, but I do not want to specify them one by one. This snippet does not make the parameters show up: { ... "paths": { "/stuff": { "get": { "description": "Gets stuff", "operationId": "getStuff", "parameters": { "$ref": "#/definitions/set1" } } } },...

Not understanding C++ type mismatch: const Foo* to Foo* const&

c++,pointers,reference,const
Having this set of objects and statements: QSet<Foo*> set; iterator QSet::insert(const T & value) //type of the function I want to call const Foo * get() const //type of the function I use to get the argument set.insert(get()); //the line showing up as error I get the error "no known...

When you reference library how to copy to TargetDir not only .dll but also .config

c#,reference,config,solution,class-library
I have an additional config file for my library. I use it to config log4net. So library can configure log4net. I add reference to the library to another project in my solution and i need to make VS copy not only .dll file, but also .config file. How can i...

References - Why do the following two programs produce different output?

c++,reference,static,output
I recently read about references in C++. I am aware of basic properties of references but I am still not able to figure out why following two programs produce different output. #include<iostream> using namespace std; int &fun() { static int x = 10; return x; } int main() { fun()...

how to use one core project for a SQL Server 2014 and Azure SQL Database

sql,database,azure,reference,sql-azure
we want to deploy our Software on different editions of SQL Server. So we made a CoreDB Project, and for every edition (Express, Standard, Enterprise) seperate projects. Each references the CoreDB to reduce the amount of objects to define. Now we want to deploy to Azure DB, but we can...

Chain linked classes

c#,arrays,reference
I have created long chains of classes, with each link(class) knowing only the next and previous link. I see great advantage over Arrays when the index is not important. public class ChainLink { public ChainLink previousLink, nextLink; // Accessors here } Questions : What is this technique actually called? (I...