global-variables

Static initialization and destruction of a static library's globals not happening with g++

巧了我就是萌 提交于 2019-12-28 12:14:45
问题 Until some time ago, I thought a .a static library was just a collection of .o object files, just archiving them and not making them handled differently. But linking with a .o object and linking with a .a static library containing this .o object are apparently not the same . And I don't understand why... Let's consider the following source code files: // main.cpp #include <iostream> int main(int argc, char* argv[]) { std::cout << "main" << std::endl; } // object.hpp #include <iostream> struct

WPF Application using a global variable

自闭症网瘾萝莉.ら 提交于 2019-12-28 11:50:07
问题 I created a WPF application in c# with 3 different windows, Home.xaml, Name.xaml, Config.xam l. I want to declare a variable in Home.xaml.cs that I can use in both the other forms. I tried doing public string wt = ""; but that didn't work. How can I make it usable by all three forms? 回答1: The proper way, especially if you ever want to move to XBAPP, is to store it in Application.Current.Properties which is a Dictionary object. 回答2: To avoid having to pass around values between windows and

WPF Application using a global variable

我的未来我决定 提交于 2019-12-28 11:50:07
问题 I created a WPF application in c# with 3 different windows, Home.xaml, Name.xaml, Config.xam l. I want to declare a variable in Home.xaml.cs that I can use in both the other forms. I tried doing public string wt = ""; but that didn't work. How can I make it usable by all three forms? 回答1: The proper way, especially if you ever want to move to XBAPP, is to store it in Application.Current.Properties which is a Dictionary object. 回答2: To avoid having to pass around values between windows and

How do I declare an array when I don't know the length until run time?

青春壹個敷衍的年華 提交于 2019-12-28 03:45:28
问题 I originally had an array[1..1000] that was defined as a global variable. But now I need that to be n, not 1000 and I don't find out n until later. I know what n is before I fill the array up but I need it to be global therefore need a way to define the size of a global array at run time. Context is filling an array with a linear transformation of the bytes in a file. I don't know how big the file is until someone wants to open it and the files can be of any size. 回答1: As of Delphi 4, Delphi

The advantage / disadvantage between global variables and function parameters in PHP?

泄露秘密 提交于 2019-12-27 14:55:19
问题 sorry i'm a beginner and i can't determine how good a question this is, maybe it sounds utterly obvious to some of you. if our use of these two below is the same which is better? function doSomething ($var1,$var2,..){ ... } OR function doSomething (){ global $var1,$var2,..; ... } by our use I mean that I know that in the second scenario we can also alter the global variables' value. but what if we don't need to do that, which is the better way of writing this function? does passing variables

Declaring variables without var keyword

ぃ、小莉子 提交于 2019-12-27 10:22:31
问题 At w3schools there is written: If you declare a variable, without using "var", the variable always becomes GLOBAL. Is it useful to declare global variable inside the function? I can imagine to declare some global variables in some event handler, but what is it good for? Better usage of RAM? 回答1: No, there's no RAM benefit or anything like that. What w3schools is talking about is something I call The Horror of Implicit Globals. Consider this function: function foo() { var variable1, variable2;

Declaring variables without var keyword

不羁的心 提交于 2019-12-27 10:21:23
问题 At w3schools there is written: If you declare a variable, without using "var", the variable always becomes GLOBAL. Is it useful to declare global variable inside the function? I can imagine to declare some global variables in some event handler, but what is it good for? Better usage of RAM? 回答1: No, there's no RAM benefit or anything like that. What w3schools is talking about is something I call The Horror of Implicit Globals. Consider this function: function foo() { var variable1, variable2;

Unable to assign output of sed or awk command to variables? Can only print them

 ̄綄美尐妖づ 提交于 2019-12-25 18:53:12
问题 I use this command to extract 2 lines from a text file: cat file1 | grep -A7 SECTIONA | grep -E 'Address|BackupAddress' This produces the two lines below: Address host1 port_1 Address BackupAddress host2 port_2 BackupAddress I need to assign (not print) the host and port columns to distinct global variables to use later in the script. hosta="host1" porta="port_1" hostb="host2" portb="port_2" A member suggested I use this and I get the desired output, however I cannot use the variables in the

Python MVC architecture Temperature Conversion: Why am I getting “NameError: global name 'view' is not defined”

岁酱吖の 提交于 2019-12-25 18:24:22
问题 This isn't a difficult question, but I can't wrap my head around it when dealing with MVC architecture (passing arguments between the VIEW, MODEL, and CONTROLLER). Error in question: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python33\lib\tkinter__init__.py", line 1482, in call return self.func(*args) File "C:\Users\Mike\Desktop\code\Assignment 6\glue.py", line 37, in buttonPressed self.model.convertTempF2C(view.fahrenheitEntrySpace.get) NameError: global name

How to “globalize” PHP variables?

旧城冷巷雨未停 提交于 2019-12-25 18:03:41
问题 I have a page named ChangeApprovalInfo.php - It has a function called Row_Rendered as follows; function Row_Rendered() { // To view properties of field class, use: //var_dump($this-><FieldName>); $RecordOwner = $this->RequestUser->CurrentValue; echo $RecordOwner; } Echoing $RecordOwner gets me the data I will need for a sql query on another page.... I have another page called ChangeApprovalEdit.php - This page has <?php include_once "ChangeApprovalinfo.php" ?> at the top of the file.