Search Results

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

Page 47/604 | < Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >

  • Linking Error: undefined reference to `MPI_Init' on Windows 7

    - by fatpipp
    I am using OpenMPI library to write a program to run on Windows 7. I compile and build with C Free 4.0, Mingw. Compiling is Ok but when the compiler links object, errors "undefined reference to ..." occurs. I have set the environment already: I added OpenMPI lib, include and bin folder into C Free Build Directories. I added them into Windows environment variables too. But the error still occurs. Can anyone tell me how to fix it? Thanks a lot.

    Read the article

  • how to avoid temporaries when copying weakly typed object

    - by Truncheon
    Hi. I'm writing a series classes that inherit from a base class using virtual. They are INT, FLOAT and STRING objects that I want to use in a scripting language. I'm trying to implement weak typing, but I don't want STRING objects to return copies of themselves when used in the following way (instead I would prefer to have a reference returned which can be used in copying): a = "hello "; b = "world"; c = a + b; I have written the following code as a mock example: #include <iostream> #include <string> #include <cstdio> #include <cstdlib> std::string dummy("<int object cannot return string reference>"); struct BaseImpl { virtual bool is_string() = 0; virtual int get_int() = 0; virtual std::string get_string_copy() = 0; virtual std::string const& get_string_ref() = 0; }; struct INT : BaseImpl { int value; INT(int i = 0) : value(i) { std::cout << "constructor called\n"; } INT(BaseImpl& that) : value(that.get_int()) { std::cout << "copy constructor called\n"; } bool is_string() { return false; } int get_int() { return value; } std::string get_string_copy() { char buf[33]; sprintf(buf, "%i", value); return buf; } std::string const& get_string_ref() { return dummy; } }; struct STRING : BaseImpl { std::string value; STRING(std::string s = "") : value(s) { std::cout << "constructor called\n"; } STRING(BaseImpl& that) { if (that.is_string()) value = that.get_string_ref(); else value = that.get_string_copy(); std::cout << "copy constructor called\n"; } bool is_string() { return true; } int get_int() { return atoi(value.c_str()); } std::string get_string_copy() { return value; } std::string const& get_string_ref() { return value; } }; struct Base { BaseImpl* impl; Base(BaseImpl* p = 0) : impl(p) {} ~Base() { delete impl; } }; int main() { Base b1(new INT(1)); Base b2(new STRING("Hello world")); Base b3(new INT(*b1.impl)); Base b4(new STRING(*b2.impl)); std::cout << "\n"; std::cout << b1.impl->get_int() << "\n"; std::cout << b2.impl->get_int() << "\n"; std::cout << b3.impl->get_int() << "\n"; std::cout << b4.impl->get_int() << "\n"; std::cout << "\n"; std::cout << b1.impl->get_string_ref() << "\n"; std::cout << b2.impl->get_string_ref() << "\n"; std::cout << b3.impl->get_string_ref() << "\n"; std::cout << b4.impl->get_string_ref() << "\n"; std::cout << "\n"; std::cout << b1.impl->get_string_copy() << "\n"; std::cout << b2.impl->get_string_copy() << "\n"; std::cout << b3.impl->get_string_copy() << "\n"; std::cout << b4.impl->get_string_copy() << "\n"; return 0; } It was necessary to add an if check in the STRING class to determine whether its safe to request a reference instead of a copy: Script code: a = "test"; b = a; c = 1; d = "" + c; /* not safe to request reference by standard */ C++ code: STRING(BaseImpl& that) { if (that.is_string()) value = that.get_string_ref(); else value = that.get_string_copy(); std::cout << "copy constructor called\n"; } If was hoping there's a way of moving that if check into compile time, rather than run time.

    Read the article

  • Advice on Minimizing Stored Procedure Parameters

    - by RPM1984
    Hi Guys, I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008 database via Entity Framework 4.0. On a particular page, i call a stored procedure in order to pull back some results based on selections on the UI. Now, the UI has around 20 different input selections, ranging from a textbox, dropdown list, checkboxes, etc. Each of those inputs are "grouped" into logical sections. Example: Search box : "Foo" Checkbox A1: ticked, Checkbox A2: unticked Dropdown A: option 3 selected Checkbox B1: ticked, Checkbox B2: ticked, Checkbox B3: unticked So i need to call the SPROC like this: exec SearchPage_FindResults @SearchQuery = 'Foo', @IncludeA1 = 1, @IncludeA2 = 0, @DropDownSelection = 3, @IncludeB1 = 1, @IncludeB2 = 1, @IncludeB3 = 0 The UI is not too important to this question - just wanted to give some perspective. Essentially, i'm pulling back results for a search query, filtering these results based on a bunch of (optional) selections a user can filter on. Now, My questions/queries: What's the best way to pass these parameters to the stored procedure? Are there any tricks/new ways (e.g SQL Server 2008) to do this? Special "table" parameters/arrays - can we pass through User-Defined-Types? Keep in mind im using Entity Framework 4.0 - but could always use classic ADO.NET for this if required. What about XML? What are the serialization/de-serialization costs here? Is it worth it? How about a parameter for each logical section? Comma-seperated perhaps? Just thinking out loud. This page is particulary important from a user point of view, and needs to perform really well. The stored procedure is already heavy in logic, so i want to minimize the performance implications - so keep that in mind. With that said - what is the best approach here?

    Read the article

  • Basic class returns object reference instead of Array

    - by php-b-grader
    I have very basic class: class Customer { protected $id; protected $customer; public function __construct($customer_id) { $this->id = $customer_id; return $this->set_customer(); } protected function set_customer() { $query = mysql_query("SELECT * FROM customer WHERE id = '$this->id'"); $this->customer = mysql_fetch_row($query); return $this->customer; } } $customer = new Customer($order->customer->id); print_r($customer); This is not doing what I want it to but I understand why... $customer returns a reference to the Customer Object... What I want is the MySQL row array from the mysql_fetch_row() - How do I return the array? What am I missing?

    Read the article

  • How to extract object reference from property access lamda

    - by Jim C
    Here's a follow-up question to http://stackoverflow.com/questions/2820660/get-name-of-property-as-a-string. Given a method Foo (error checking omitted for brevity): // Example usage: Foo(() => SomeClass.SomeProperty) // Example usage: Foo(() => someObject.SomeProperty) void Foo(Expression<Func<T>> propertyLambda) { var me = propertyLambda.Body as MemberExpression; var pi = me.Member as PropertyInfo; bool propertyIsStatic = pi.GetGetMethod().IsStatic; object owner = propertyIsStatic ? me.Member.DeclaringType : ???; ... // Execute property access object value = pi.GetValue(owner, null); } I've got the static property case working but don't know how to get a reference to someObject in the instance property case. Thanks in advance.

    Read the article

  • C++: How do I pass a function(without knowing its parameters) to another function?

    - by Ninja
    Hi all. I'm trying to create a function that will store and repeat another function given as a parameter for a specific amount of time or repeats given. But when you want to pass a function as a parameter you have to know all of its parameters before hand. How would I do if I wanted to pass the function as one parameter, and the parameters as another? void AddTimer(float time, int repeats, void (*func), params); // I know params has no type and that (*func) is missing parameters but it is just to show you what I mean Thanks in advance

    Read the article

  • Javascript function programming — receiving elaborate parameters

    - by Barney
    I'm writing a Javascript function that would manipulate an array written on-the-fly and sent as a parameter. The function is written as follows: function returnJourney(animation,clean){ var properties = {}; // loads of other inane stuff for(i in animation[0]) properties[animation[0][i]] = animation[0].i; // heaps more inane stuff } The animation in question is a set of parameters for a jQuery animation. Typically it takes the format of ({key:value,key:value},speedAsInteger,modifierAsString). So to kick off initial debugging I call it with: returnJouney(({'foo':'bar'},3000),1); And straight off the bat things are way off. As far as I see it this would have returnJourney acknowledge clean === 1, and animation being an array with an object as its first child and the number 3000 as its second. Firebug tells me animation evaluates as the number 3000. What am I doing wrong?

    Read the article

  • Scala : reference is ambiguous (imported twice)

    - by tk
    I want to use a method as a parameter of another method of the same class. I have a class and objects which are companions: class mM(var elem:Matrix){ //apply a function on a dimension rows (1) or cols (2) def app(func:Iterable[Double]=>Double)(dim : Int) : Matrix = { ... } //utility function def logsumexp(): Double = {...} } object mM{ def apply(elem:Matrix):mM={new mM(elem)} def logsumexp(elem:Iterable[Double]): Double ={ this.apply(elem.asInstanceOf[Matrix]).logsumexp() } } Normally I use logsumexp like this mM(matrix).logsumexp but if want to apply it to the rows I can't use mM(matrix).app(mM.logsumexp)(1), I get the error: error: reference to mM is ambiguous; it is imported twice in the same scope by import mM and import mM What is the most elegant solution ? Should I change logsumexp() to another class ? Thanks,=)

    Read the article

  • C undefined reference to `some_foo'

    - by sterh
    Hello, I have 3 files in my gtk+ app: main.c: #include <gtk/gtk.h> #include <glib/gi18n.h> #include "mainwindow.h" int main(int argc, char** argv) { MainWin* win; GError* err = NULL; int a = 0; a = some_foo(); gtk_main(); return 0; } mainwindo.h #include <gtk/gtk.h> typedef struct _MainWin { GtkWindow parent; } MainWin; GtkWidget* main_win_new(); int some_foo(); MainWindow.c #include "mainwindow.h" int some_foo() { return 1; } When i try to call some_foo in main function, and try to compile i see error: undefined reference to `some_foo'. What's wrong? Thank you.

    Read the article

  • update value of a variable outside a class in VB.NET

    - by dpp
    I have a class derived from a Form, it has textbox for username and password and an OK button. I want it to behave like an InputBox so I can use it like this: Dim Username As String = "" Dim Password As String = "" Dim authorization As New Authorization(Username, Password) authorization.ShowDialog() 'The user will click OK and I will expect the Username and Password to change based on the user input MsgBox(Username & " " & Password) The Authorization class: Public Class Authorization Dim RefUsername As String Dim RefPassword As String Public Sub New(ByRef Username As String, ByRef Password As String) InitializeComponent() RefUsername = Username 'I'm trying to pass reference instead of value RefPassword = Password 'I'm trying to pass reference instead of value End Sub Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AuthorizeButton.Click RefUsername = Username.Text 'I'm trying to change value of variable outside the class RefPassword = Password.Text 'I'm trying to change value of variable outside the class Me.Close() End Sub End Class In short, I want to change the value of variables outside the class when the user clicks the OK, how am I going to accomplish that?

    Read the article

  • undefined reference to "func" when complied with GCC

    - by hotlemontea
    I implement a link list in two files in linklist.h and linklist.c, and I call some functions defined in linklist.h in main function of main.c. linklist.h is included in both linklist.c and main.c. When I compile this program by GCC with Makefile, the error named "undefined reference to xxx" occurs. I think my Makefile is written correctly as below. So what is the possible reason for this linking error CC=gcc CFLAGS= -g -O2 TARGET=target OBJECTS=main.o linklist.o TARGET: $(OBJECTS) $(CC) $(CFLAGS) $(OBJECTS) -o $(TARGET) clean: rm target $(OBJECTS) main.o:linklist.h linklist.o:linklist.h

    Read the article

  • 2 dimensional arrays passed to a function in c++

    - by John Marcus
    I'm working on doing calculations in a two dimensional array but keep getting a nasty error. i call the function by : if(checkArray(array)) and try to pass it in like this: bool checkArray(double array[][10]) //or double *array[][10] to no avail the error is error: cannot convert ‘double ()[(((unsigned int)(((int)n) + -0x00000000000000001)) + 1)]’ to ‘double’ for argument ‘1’ to ‘bool checkArray(double*)’ code snippet //array declaration int n = 10; double array[n][n]; //function call to pass in array while(f != 25) { cout<<endl; cout<<endl; if(checkArray(array)) //this is the line of the error { cout<<"EXIT EXIT EXIT"<<endl; } f++; } //function declaration bool checkArray(double *array)//, double newArray[][10]) { double length = sizeof(array); for(int i = 0; i < length; i++) for(int j = 0; j < length;j++) { double temp = array[i][j]; } }

    Read the article

  • Circular reference while setting up bidirectional communication line between two remote objects

    - by mphair
    I'm using .Net remoting to set up a bidirectional communication line between two objects. The basic structure is as follows: Instances of RemoteObjectA call methods on StaticObjectA. Instances of RemoteObjectB call methods on StaticObjectB. StaticObjectA needs to be able to call methods provided by RemoteObjectB. StaticObjectB needs to be able to call methods provided by RemoteObjectA. The problem with this setup is the circular reference in RemoteObjectA gets StaticObjectA gets RemoteObjectB gets StaticObjectB gets RemoteObjectA... I implemented an interface IRemoteObjectA and IRemoteObjectB and had the remote objects inheret from their respective interfaces, but then setting up the remoting fails. If the solution to this problem is: "don't use remoting", I can deal with that. Just wanted to make sure I wasn't missing a simple solution.

    Read the article

  • Adding an keyUp-event to form objects

    - by reporter
    Hello folks, I've got the issue to add a browser event to some input fields. The challenge I have to face is, that one parameter of my target function is the 'event'-variable and the second one an object. For a better understanding here some codes:The HTML object: <div id="1_dateFieldAdvanced" class="xp set"> <div id="1_dateFieldAdvanced_label" class="label">Birthday</div> <div id="1_dateFieldAdvanced_value" class="value date"> <input class="day" name="dayOfBirth" value="66" maxlength="2" type="text"> <input class="month" name="monthOfBirth" value="67" maxlength="2" type="text"> <input class="year" name="yearOfBirth" value="" maxlength="4" type="text"> </div> </div> The source code of target method is like below: function advancedDateFields(currentFieldAsObject, nextField, currentValueLength, ev){} Unfortunatly the HTML and the Javascript code is generated automatically, so I'm unable to refactore the code. My question is, how can I pass the key word 'event' and the other parameters? My tries did always fail. :-(

    Read the article

  • Entity Framework 4.0 - Code only Reference

    - by joe
    Hello All, I am trying to learn EF 4 and its code only features. I tried the following great articles and was able to make a sample application. http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/#reply http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx But I am looking for a good reference library / website on Code only feature. I tried searching MSDN but couldn't find it. Please help. Thanks a lot.

    Read the article

  • c# - best way to initialize an array of reference type object

    - by lidong
    I wonder if there is better way to initialize an array of reference type object, like this. Queue<int>[] queues = new Queue<int>[10]; for (int i = 0; i < queues.Length; i++) { queues[i] = new Queue<int>(); } I tried Enumerable.Repeat, but all elements in the array refer to same instance, Queue<int>[] queues = Enumerable.Repeat(new Queue<int>(), 10).ToArray(); I also tried Array.ForEach, but it doesn't work without ref keyword: Queue<int>[] queues = Array.ForEach(queues, queue => queue = new Queue<int>()); any other idea?

    Read the article

  • Object reference not set to an instance of an object

    - by Ste
    I have this function that create runtime textbox: int i = 0; private TextBox[] addressBox = new TextBox[100]; private void appendNewTab() { addressBox[i] = new TextBox(); addressBox[i].KeyPress += new KeyPressEventHandler(this.addressBox_KeyPress); i++; } void addressBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { MessageBox.Show(addressBox[i].Text); } } but i have Object reference not set to an instance of an object here MessageBox.Show(addressBox[i].Text); any suggestion?

    Read the article

  • Set argument pointer to point to new memory inside a function (without returning it) IN C

    - by user321605
    Hello, Hopefully my title was descriptive enough to attract the right help. I want to write a function that will return 1 thing, and modify a provided pointer in another. My current function declaration is . . . char * afterURL replaceURLS(char * body) What I want to do is copy all of body's data into a new string, and set body to point to this new data. I then want afterURL to point to a location within the new string. My issue is getting the actual pointer that is passed in to this function to point to the new data. Thanks in advance! Rob

    Read the article

  • Undefined reference to "func" when compiled with GCC

    - by hotlemontea
    I implement a link list in two files in linklist.h and linklist.c, and I call some functions defined in linklist.h in main function of main.c. linklist.h is included in both linklist.c and main.c. When I compile this program by GCC with Makefile, the error named "undefined reference to xxx" occurs. I think my Makefile is written correctly as below. So what is the possible reason for this linking error CC=gcc CFLAGS= -g -O2 TARGET=target OBJECTS=main.o linklist.o TARGET: $(OBJECTS) $(CC) $(CFLAGS) $(OBJECTS) -o $(TARGET) clean: rm target $(OBJECTS) main.o:linklist.h linklist.o:linklist.h

    Read the article

  • How to Pass complex objects in ASP.NET MVC using Get parameters?

    - by VJ
    I am wanting to pass something like the following to my view from my controller via GET not POST: public class MyDTO { public string val1 { get; set; } public string val2 { get; set; } public MyObject obj { get; set; } } public class MyObject { public int SomeInt { get; set; } public string ACoolValue { get; set; } public string YetAnotherCoolValue { get; set; } } And then the controller would like like this. (Note it is a GET): public ActionResult MyView(MyDTO dto) { return View(dto) } The problem is that the instance of MyObject is coming back as null, where val1 and val2 have data. Has anyone run across this?

    Read the article

  • CodeContracts: Possibly calling a method on a null reference

    - by dtb
    I'm having an argument with the CodeContracts static analysis tool. My code: class Foo { private static Foo instance = new Foo(); private string bar; public Foo() { bar = "Hello World"; } public static int BarLength() { return instance.bar.Length; // <<-- } } The tool tells me that instance.bar may be a null reference. I believe the opposite. Who is right? How can I prove it wrong?

    Read the article

  • How to code the set method of a Map with another Map as value?

    - by Nazgulled
    I normally do this to set a new Map to a private variable: public static void setListaClausulas(Map<String, Clausula> nvLista) { listaClausulas = new TreeMap<String, Clausula>(nvLista); } I suppose this is ok to set a new copy of the nvLista and all it's members and not a reference, is it? But now I have a Map inside another Map and I'm doing this: public static void setListaClausulas(Map<String, Map<String, Clausula>> nvLista) { listaClausulas = new TreeMap<String, Map<String, Clausula>>(nvLista); } Is this the correct way to do it or do you recommend something else? What I want is to set a new copy of nvLista (and all it's elements) and not copy just the reference.

    Read the article

  • servlet authentication and further reference to the credentials

    - by user553592
    What I got so far: It all begins with an HTML form which prompts the user for a username and password. From there it post the acquired user/pass to a servlet, GateKeeper. GateKeeper determines if the user/pass combination match any records in the MySQL database. Here is the sql I use: SELECT id FROM Users WHERE username='?' AND password=MD5('?') where the ? indicate information provided the previous HTML form. What I need now: I need some way to store the username and id of the record in the database. GateKeeper redirects the user to a control panel upon success. Therefore, I need a method to reference the username to display simple greetings, etc and also the id so it eliminates unnecessary calls to the database. The control panel may make AJAX calls to Servlets that preform some sort of task to the MySQL database.

    Read the article

< Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >