Search Results

Search found 15081 results on 604 pages for 'passing by reference'.

Page 8/604 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Python - copy by reference

    - by qba
    Is there any possibility to copy variable by reference no matter if its int or class instance? My goal is to have two lists of the same objects and when one changes, change is visible in second. In other words i need pointers:/

    Read the article

  • "undefined reference" error with namespace across multiple files

    - by user1330734
    I've looked at several related posts but no luck with this error. I receive this undefined reference error message below when my namespace exists across multiple files. If I compile only ConsoleTest.cpp with contents of Console.cpp dumped into it the source compiles. I would appreciate any feedback on this issue, thanks in advance. g++ Console.cpp ConsoleTest.cpp -o ConsoleTest.o -Wall /tmp/cc8KfSLh.o: In function `getValueTest()': ConsoleTest.cpp:(.text+0x132): undefined reference to `void Console::getValue<unsigned int>(unsigned int&)' collect2: ld returned 1 exit status Console.h #include <iostream> #include <sstream> #include <string> namespace Console { std::string getLine(); template <typename T> void getValue(T &value); } Console.cpp #include "Console.h" using namespace std; namespace Console { string getLine() { string str; while (true) { cin.clear(); if (cin.eof()) { break; // handle eof (Ctrl-D) gracefully } if (cin.good()) { char next = cin.get(); if (next == '\n') break; str += next; // add character to string } else { cin.clear(); // clear error state string badToken; cin >> badToken; cerr << "Bad input encountered: " << badToken << endl; } } return str; } template <typename T> void getValue(T &value) { string inputStr = Console::getLine(); istringstream strStream(inputStr); strStream >> value; } } ConsoleTest.cpp #include "Console.h" void getLineTest() { std::string str; std::cout << "getLinetest" << std::endl; while (str != "next") { str = Console::getLine(); std::cout << "<string>" << str << "</string>"<< std::endl; } } void getValueTest() { std::cout << "getValueTest" << std::endl; unsigned x = 0; while (x != 12345) { Console::getValue(x); std::cout << "x: " << x << std::endl; } } int main() { getLineTest(); getValueTest(); return 0; }

    Read the article

  • Powershell: splatting after passing hashtable by reference

    - by user1815871
    Powershell newbie ... I recently learned about splatting — very useful. I ran into a snag when I passed a hash table by reference to a function for splatting purposes. (For brevity's sake — a silly example.) Function AllMyChildren { param ( [ref]$ReferenceToHash } get-childitem @ReferenceToHash.Value # etc.etc. } $MyHash = @{ 'path' = '*' 'include' = '*.ps1' 'name' = $null } AllMyChildren ([ref]$MyHash) Result: an error ("Splatted variables cannot be used as part of a property or array expression. Assign the result of the expression to a temporary variable then splat the temporary variable instead."). Tried this afterward: $newVariable = $ReferenceToHash.Value get-childitem @NewVariable That did work and seemed right per the error message. But: is it the preferred syntax in a case like this? (An oh, look, it actually worked solution isn't always a best practice. My approach here strikes me as "Perl-minded" and perhaps in Powershell passing by value is better, though I don't yet know the syntax for it w.r.t. a hash table.)

    Read the article

  • passing reference of class to another class android error

    - by prolink007
    I recently asked the precursor to this question and had a great reply. However, when i was working this into my android application i am getting an unexpected error and was wondering if everyone could take a look at my code and help me see what i am doing wrong. Link to the initial question: passing reference of class to another class My ERROR: "The constructor ConnectDevice(new View.OnClickListener(){}) is undefined" The above is an error detected by eclipse. Thanks in advance! Below are My code snippets: public class SmartApp extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.intro); final Button connectDeviceButton = (Button) findViewById(R.id.connectDeviceButton); connectDeviceButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Thread cThread = new Thread(new ConnectDevice(this)); cThread.start(); } }); } } public class ConnectDevice implements Runnable { private boolean connected; private SmartApp smartAppRef; private ObjectInputStream ois; public ConnectDevice(SmartApp smartAppRef) { this.smartAppRef = smartAppRef; } }

    Read the article

  • Passing arguments by value or by reference in objective C

    - by Rafael
    Hello, I'm kind of new with objective c and I'm trying to pass an argument by reference but is behaving like it were a value. Do you know why this doesn't work? This is the function: - (void) checkRedColorText:(UILabel *)labelToChange { NSComparisonResult startLaterThanEnd = [startDate compare:endDate]; if (startLaterThanEnd == NSOrderedDescending){ labelToChange.textColor = [UIColor redColor]; } else{ labelToChange.textColor = [UIColor blackColor]; } } And this the call: UILabel *startHourLabel; (this is properly initialized in other part of the code) [self checkRedColorText:startHourLabel]; Thanks for your help

    Read the article

  • reference to specific hash key

    - by dave
    How do I create a reference to the value in a specific hash key. I tried the following but $$foo is empty. Any help is much appreciated. $hash->{1} = "one"; $hash->{2} = "two"; $hash->{3} = "three"; $foo = \${$hash->{1}}; $hash->{1} = "ONE"; #I want "MONEY: ONE"; print "MONEY: $$foo\n";

    Read the article

  • Exception while trying to reference LINQ namespace

    - by MarceloRamires
    While trying to use linq in a .NET 2.0 winforms project I got: Namespace or type specified in the Imports 'System.Linq' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases In both the lines that reference the following namespaces: System.Linq; System.Xml.Linq; How could I get these namespaces to work on .NET 2.0 without referencing an external DLL or anything ?

    Read the article

  • TMS320C64x Quick start reference for porgrammers

    - by osgx
    Hello Is thare any quickstart guide for programmers for writing DSP-accelerated appliations for TMS320C64x? I have a program with custom algorythm (not the fft, or usial filtering) and I want to accelerate it using multi-DSP coprocessor. So, how should I modify source to move computation from main CPU to DSPs? What limitations are there for DSP-running code? I have some experience with CUDA. In CUDA I should mark every function as being host, device, or entry point for device (kernel). There are also functions to start kernels and to upload/download data to/from GPU. There are also some limitations, for device code, described in CUDA Reference manual. I hope, there is an similar interface and a documentation for DSP.

    Read the article

  • pointer reference type

    - by Codenotguru
    I am trying to write a function that takes a pointer argument, modifies what the pointer points to, and then returns the destination of the pointer as a reference. I am gettin the following error: cannot convert int***' toint*' in return| Code: #include <iostream> using namespace std; int* increment(int** i) { i++; return &i;} int main() { int a=24; int *p=&a; int *p2; p2=increment(&p); cout<<p2; } Thanks for helping!

    Read the article

  • reference parent class function in AS 3.0

    - by vasion
    I am trying to run a function of the main class, but even with casting it does not work. I get this error TypeError: Error #1009: Cannot access a property or method of a null object reference. at rpflash.communication::RPXMLReader/updateplaylist() at rpflash.communication::RPXMLReader/dataHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::XMLSocket/scanAndSendEvent() this is the main class code package{ import flash.display.MovieClip; import rpflash.communication.RPXMLReader; public class Main extends MovieClip{ var reader:RPXMLReader = new RPXMLReader(); public function Main(){ trace('Main actionscript loaded'); } public function test(){ trace('test worked');} } } and this is the function trying to call it: private function updateplaylist(){ //xml to string var xmls:String= xml.toXMLString(); trace('playlist updated debug point'); MovieClip(this.parent).test();} what am i doing wrong?

    Read the article

  • Add reference to .dll asp.net

    - by Andy
    Hi, I have a simple question about adding references to a .NET project. I'm adding reCAPTCHA to a website and i have downloaded the dll. After setting the reference to the dll i build and run the project and gets this error: [ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.] System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) +0 System.Reflection.Assembly.GetTypes() +96 StarSuite.Core.Settings.GetSingletonInstancesOfBaseType(Type baseType, String staticMethodName, Type returnType) +149 [ApplicationException: Unable to load types from 'Recaptcha, Version=1.0.5.0, Culture=neutral, PublicKeyToken=9afc4d65b28c38c2'. LoaderExceptions: [FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] ] What am i missing, why do i get this error?

    Read the article

  • Model-Controller cyclic reference/design problem

    - by jasamer
    I have a CoreData entity X, and controllers for this entity, XController. Now there's another entity, XGroup, containing a collection of X entities, and a XGroupController. Now the problem is that XGroupController needs to interact with XController, and it would be nice to just pass XGroupController a XGroup to observe, and then get the XControllers from the X entities. So the question is: is it a good idea to store a (weak, to avoid retain cycles) reference to a controller in an entity? It just feels a bit "wrong". Is there another design pattern for this?

    Read the article

  • Silverlight 3-4 reference kind (e-)book.

    - by Bubba88
    Hello! I'm looking for a source of information about Microsoft Silverlight to begin practically efficient programming custom functionality applications. I want to pretend just for now that I don't need any ideologically correct refresher (SL tips, top patterns, VS tutorials :) and etc.). Basically, what I want is a reference kind e-book, where I could find any practically relevant info outlined in a minimalistic manner. If you do remember something fitting the above description, I ask you to give me a hint. Thank you very much!

    Read the article

  • Input system reference trouble

    - by Ockonal
    Hello, I'm using SFML for input system in my application. size_t WindowHandle; WindowHandle = ...; // Here I get the handler sf::Window InputWindow(WindowHandle); const sf::Input *InputHandle = &InputWindow.GetInput(); // [x] Error At the last lines I have to get reference for the input system. Here is declaration of GetInput from documentation: const Input & sf::Window::GetInput () const The problem is: >invalid conversion from ‘const sf::Input*’ to ‘sf::Input*’ What's wrong?

    Read the article

  • HTML character reference display problems.

    - by Bren
    Hey folks, I'm currently developing a site in Joomla, and one of the components I'm using makes use of a PHP file to administer the language. (english.php, spanish.php) The problem I'm having is that if I use the plain text version of eg. "á", it will show up in the browser tab title ok, but as a ? in the body of the page. But if I use a character reference (&#225;), the reverse happens! Any ideas? Thanks bren

    Read the article

  • Profile:Object reference not set to an instance of an object

    - by sallalman83
    Hi, i just lunch my web site i used the asp.net routing technology on it, and its work fine in my localhost but when i moved the project to the hosting server(Godaddy.com) its just work fine when there is no virtual sub directories like this(havebreak.com) but when u click on this link (havebreak.com/Registration/) or any other links that contain a virtual sub-directories its give Object reference not set to an instance of an object error on the profile object if (!Profile.IsAnonymous) Line 18: mlvRegistratioin.ActiveViewIndex = 1; i check my IIS settings and found it using the "Integrated pipeline" as recommended (at least at my knowledge), i checked the httpModules and httpHandlers tags under the system.webServer (since my hosting plan use the IIS7) and under the normal tag and every thing is fine then i used the url-rewriting instead of URL-Routing and the same problem exist and i notice that the session also not working in the virtual sub-directories too and by the way the ASP.NET routing work fine with my site its just the profile and session objects that not workin any help will be appreciated

    Read the article

  • Should I make OR operator to return const reference or just reference

    - by Yan Cheng CHEOK
    class error_code { public: error_code() : hi(0), lo(0) {} error_code(__int64 lo) : hi(0), lo(lo) {} error_code(__int64 hi, __int64 lo) : hi(hi), lo(lo) {} error_code& operator|=(const error_code &e) { this->hi |= e.hi; this->lo |= e.lo; return *this; } __int64 hi; __int64 lo; }; error_code operator|(const error_code& e0, const error_code& e1) { return error_code(e0.hi | e1.hi, e0.lo | e1.lo); } int main() { error_code e0(1); error_code e1(2); e0 |= e1; } I was wondering, whether I should make operator|= to return a const error_code& or error_code& ?

    Read the article

  • Undefined reference to ...

    - by Patrick LaChance
    I keep getting this error message every time I try to compile, and I cannot find out what the problem is. any help would be greatly appreciated: C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::List()' C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::add(int)' collect2: ld returned 1 exit status code: //List.h #ifndef LIST_H #define LIST_H #include <exception> //brief Definition of linked list class class List { public: /** \brief Exception for operating on empty list */ class Empty : public std::exception { public: virtual const char* what() const throw(); }; /** \brief Exception for invalid operations other than operating on an empty list */ class InvalidOperation : public std::exception { public: virtual const char* what() const throw(); }; /** \brief Node within List */ class Node { public: /** data element stored in this node */ int element; /** next node in list */ Node* next; /** previous node in list */ Node* previous; Node (int element); ~Node(); void print() const; void printDebug() const; }; List(); ~List(); void add(int element); void remove(int element); int first()const; int last()const; int removeFirst(); int removeLast(); bool isEmpty()const; int size()const; void printForward() const; void printReverse() const; void printDebug() const; /** enables extra output for debugging purposes */ static bool traceOn; private: /** head of list */ Node* head; /** tail of list */ Node* tail; /** count of number of nodes */ int count; }; #endif //List.cpp I only included the parts of List.cpp that might be the issue #include "List.h" #include <iostream> #include <iomanip> using namespace std; List::List() { //List::size = NULL; head = NULL; tail = NULL; } List::~List() { Node* current; while(head != NULL) { current = head-> next; delete current->previous; if (current->next!=NULL) { head = current; } else { delete current; } } } void List::add(int element) { Node* newNode; Node* current; newNode->element = element; if(newNode->element > head->element) { current = head->next; } else { head->previous = newNode; newNode->next = head; newNode->previous = NULL; return; } while(newNode->element > current->element) { current = current->next; } if(newNode->element <= current->element) { newNode->previous = current->previous; newNode->next = current; } } //main.cpp #include "List.h" #include <iostream> #include <string> using namespace std; //void add(int element); int main (char** argv, int argc) { List* MyList = new List(); bool quit = false; string value; int element; while(quit==false) { cin>>value; if(value == "add") { cin>>element; MyList->add(element); } if(value=="quit") { quit = true; } } return 0; } I'm doing everything I think I'm suppose to be doing. main.cpp isn't complete yet, just trying to get the add function to work first. Any help will be greatly appreciated.

    Read the article

  • Flash CS, reference root from external class

    - by Lotus
    Hi, I made this class and I put it in the same package of Timeline.as (the Document Class): package { import flash.utils.Timer; import flash.events.TimerEvent; public class Counter2 extends Timer { public function Counter2(delay:Number, repeatCount:int=0) { super(delay, repeatCount); super.addEventListener(TimerEvent.TIMER, timerHandler); } public override function start():void { super.start(); } public override function stop():void { super.stop(); } public function timerHandler(evt:TimerEvent) { trace(evt.target.currentCount); } } } This class is instanciated in Timeline.as constructor. Is there any way to reference Timeline(root) from this class? And, if so, how? Thanks!

    Read the article

  • Passing Reference types by value in C#

    - by Ajit
    I want to pass a reference type by value to a method in C#. Is there a way to do it. In C++, I could always rely on the copy constructor to come into play if I wanted to pass by Value. Is there any way in C# except: 1. Explicitly creating a new object 2. Implementing IClonable and then calling Clone method. Here's a small example: Let's take a class A in C++ which implements a copy constructor. A method func1(Class a), I can call it by saying func1(objA) (Automatically creates a copy) Does anything similar exist in C#. By the way, I'm using Visual Studio 2005.

    Read the article

  • Store return value of function in reference C++

    - by Ruud v A
    Is it valid to store the return value of an object in a reference? class A { ... }; A myFunction() { A myObject; return A; } //myObject goes out of scope here void mySecondFunction() { A& mySecondObject = myFunction(); } Is it possible to do this in order to avoid copying myObject to mySecondObject? myObject is not needed anymore and should be exactly the same as mySecondObject so it would in theory be faster just to pass ownership of the object from one object to another. (This is also possible using boost shared pointer but that has the overhead of the shared pointer.) Thanks in advance.

    Read the article

  • Circular reference problem Singleton

    - by Ismail
    I'm trying to creating a Singleton class like below where MyRepository lies in separate DAL project. It's causing me a circular reference problem because GetMySingleTon() method returns MySingleTon class and needs its access. Same way I need MyRepository access in constructor of MySingleTon class. public class MySingleTon { static MySingleTon() { if (Instance == null) { MyRepository rep = new MyRepository(); Instance = rep.GetMySingleTon(); } } public static MySingleTon Instance { get; private set; } public string prop1 { get; set; } public string prop2 { get; set; } }

    Read the article

  • Difference of function argument as (const int &) and (int & a) in C++

    - by Narek
    I know that if you write void function_name(int& a), then function will not do local copy of your variable passed as argument. Also have met in literature that you should write void function_name(const int & a) in order to say compiler, that I dont want the variable passed as argument to be copied. So my question: what is the difference with this two cases (except that "const" enshures that the variable passes will not be changed by function!!!)???

    Read the article

  • C++: Template functor cannot deduce reference type

    - by maciekp
    I've got a functor f, which takes a function func and a parameter t of the same type as func. I cannot pass g to f because of compilation error (no matching function for call to f(int&, void (&)(int&)) ). If g would take non-reference parameter g(int s), compilation finishes. Or if I manually specify template parameter f(i, g), compilation also finishes. template<typename T> void f(T t, void (*func)(T)) {} void g(int& s) {} int main(int, char*[]) { int i = 7; f(i, g); // compilation error here return 0; } How can I get deduction to work?

    Read the article

  • Javascript pass reference by value

    - by Carlos R. Batista
    Im having this weird reference issue when im trying to get a JSON file through query: var themeData; $.getJSON("json/sample.js", function(data) { themeData = data.theme; console.log(themeData.sample[0].description); }); console.log(themeData.sample[0].description); The first console.log works, the second doesnt. Im guessing because "data" already expired by the time the script gets there and themeData is just a mere pointer to "data". Is there a ways I can make sure themeData gets a duplicate of "data" and not just a pointer to it?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >