reference

Returning a local object from a function

Is this the right way to return an object from a function? Car getCar(string model, int year) { Car c(model, year); return c; } void displayCar(Car &car) { cout << car.getModel() << ", " << car.getYear() << endl; } displayCar(getCar("Honda", 1999)); I'm getting an error, "taking address of temporary". Should I use this way:...

.htaccess reference with examples

Hi all! Need link, if it exist, to good and full .htaccess reference with examples. Thanks. ...

Objective-C : Member variable is losing reference between method calls.

Hello, I've been having with an objective-c class which appears to be losing its pointer reference between methods of the same class. In the MyTableViewController.h file, I declare: @interface SettingsTableViewController : UITableViewController <UITextFieldDelegate>{ OCRAppDelegate *delegate; } MyTableViewController.m file - (i...

Calling a method of a constant object parameter

Here is my code that fails: bool Table::win(const Card &card) { for (int i = 0; i < cards.size(); i++) if (card.getRank() == cards[i].getRank()) return true; return false; } Error message is: passing 'const Card' as 'this' argument of 'int Card::getRank()' discards qualifiers. When I get a copy of the card and change the...

Value get changed even though I'm not using reference

In code: struct Rep { const char* my_data_; Rep* my_left_; Rep* my_right_; Rep(const char*); }; typedef Rep& list; ostream& operator<<(ostream& out, const list& a_list) { int count = 0; list tmp = a_list;//----->HERE I'M CREATING A LOCAL COPY for (;tmp.my_right_;tmp =...

[Perl] Retrieve the reference

Hello, with the hash below, I would like the clients array's reference : my $this = { 'name' => $name, 'max_clients' => $max_clients, 'clients' => () }; I can't do "\$this{'clients'};" to retrieve the reference. ...

Iwork Numbers Spreadsheet Referencing

I am new to Mac Numbers. I would like to know if there is a way that one spreadsheet file can reference the values from a completely different spreadsheet file. ...

How can I take a reference to a Perl subroutine?

I'm having some trouble figuring out how to make a reference to a subroutine in an external module file. Right now, I'm doing this: External file package settingsGeneral; sub printScreen { print $_[0]; } Main use settingsGeneral; my $printScreen = settingsGeneral::printScreen; &$printScreen("test"); but this result int...

Swap references at build time in VS

I have a project that runs on both .NET and .NET CF. But it uses a 3rd party library that will not run on both. So I end up changing the reference every time the project gets built. Project A - References the 3rd party dll. Project B - References A and runs .NET CF Project C - References A and runs .NET Is there a way to automate it?...

The Community-Driven GDB Primer

I was reading this question and realized it might be helpful for entry- and pro-level developers alike (including myself) to have a common reference for best practices in using gdb. Many questions asked on Stack Overflow could easily be solved by taking some time to step some code in a debugger, and it would be good to have a community-...

Strange PHP reference bug

Hello, I have a really strange bug with my PHP code. I have a recursive code which build up a menu tree with object and one of my customers server can't make it work. Contructor: function Menu(&$menus, &$keys , &$parent, &$menu){ ... if($keys === NULL){ $keys = array_keys($menus); } ... ...

C++ constant reference lifetime

hello I have code that looks like this: class T {}; class container { const T &first, T &second; container(const T&first, const T & second); }; class adapter : T {}; container(adapter(), adapter()); I thought lifetime of constant reference would be lifetime of container. However, it appears otherwise, adapter object is destroyed...

XmlDocument type not found even though I've referenced System.XML ?

I've referenced System.Xml: using System.Xml; Then in this line: XmlDocument xdoc = new XmlDocument(); I get: The type or namespace name 'XmlDocument' could not be found What could there possibly be wrong ? Info: .NET 3.5, C#, triple checked that it's referenced and used in the same document, been able to use similar and ...

Pointer-like behavior in Java

I got the following: class A{ int foo; } class B extends A{ public void bar(); } I got a instance of A and want to convert it to an instance of B without losing the reference to the variable foo. For example: A a = new A(); a.foo = 2; B b = a; <-- what I want to do. //use b b.foo = 3; //a.foo should now b...

How to get ref of an array in PHP 5 ?

In php 5, all variable and objects are passed by reference, but i can't get my codes work My codes is: $arrayA = array(); $array = $arrayA; ... if(!in_array(thedata, $array) $array[] = thedata; var_dump($arrayA); The result is empty, am i missing something simple? ...

Where can I find a definitive reference on HTML 5 database SQL syntax support?

Does anyone know of a good online resource which gives a clear reference on the SQL syntax supported by HTML 5 client-side databases? I've looked about and cannot seem to locate one. Thanks ...

C++ Returning a Reference

Consider the following code where I am returning double& and a string&. The thing works fine in the case of a double but not in the case of a string. Why is this difference in the behavior? In both the cases compiler does not even throws the Warning: returning address of local variable or temporary as I am returning a reference. #inclu...

AS 3.0 reference problem

I am finding it hard to fugure out the reference system in AS 3.0. this is the code i have (i have trimmed it down in order to find the problem but to no avail) package rpflash.ui { import flash.display.Sprite; import flash.display.MovieClip; import flash.display.Stage; import nowplaying; import flash.text.TextField; public class RP...

Visual Studio - Attach Source Code to Reference

My C# project references a third-party DLL for which I have the source code. Can I somehow tell Visual Studio the location of that source code, so that, for example, when I press F12 to open the definition of a method in the DLL, it will open up the source code, instead of opening up the "Class [from metadata]" stub code? ...

Return reference from class to this.

Hi, I have the following member of class foo. foo &foo::bar() { return this; } But I am getting compiler errors. What stupid thing am I doing wrong? Compiler error (gcc): error: invalid initialization of non-const reference of type 'foo&' from a temporary of type 'foo* const' ...