scope

C++ header file variable scope issue

Hi, I've got 3 files that relate to this problem. file.h, file.C and user.C. file.h has a private member, fstream logs. In file.C's constructor it opens logs. It doesn't do this in the constructor, but the constructor calls a function OpenLog(). file.h also has an inline close function: CloseLog() {if (logs) logs.close();} The f...

Java: Anonymous inner class using a local variable

How can I get the value of userId passed to this method in my anonymous inner subclass here? public void doStuff(String userID) { doOtherStuff(userID, new SuccessDelegate() { @Override public void onSuccess() { Log.e(TAG, "Called delegate!!!! "+ userID); } }); } I get this error: Cannot ...

Determining how many functions are declared at the global scope

Is there any way to determine how many or what functions are defined at certain scope?, let's say the global scope... I don't think so, but I give it a try here EDIT: looping through window properties does not work in IE for this purpose. Is it doable in IE? ...

JavaScript: global scope

Nowdays, i create a .js file with a lot of functions and then I link it to my html pages. That's working but I want to know what's the best way (good practices) to insert js in my pages and avoid conflicts with scope... Thank you. ...

PHP scope between two classes

Hello... I have a few files like below: index.php: require_once("foo.php"); require_once("bar.php"); foo.php: class foo { function1() { } } bar.php: class bar { ????? } My question is, is there any way of accessing function1 from the foo class in the bar class, without having to include the foo.php file in the ba...

Forward declaring classes in namespaces

I was rather surprised to learn that I couldn't forward declare a class from another scope using the scope resolution operator, i.e. class someScope::someClass; Instead, the full declaration has to be used as follows: namespace { class someClass; } Can someone explain why this is the case? UPDATE: To clarify, I am asking why t...

Is it proper to use the term "global" in a relative sense?

Please assume the following contrived JavaScript: function do_something() { var x = 5; function alert_x() { alert(x); } alert_x(); } do_something(); The variable x is local to the function do_something. It isn't a global variable because it's not available in every scope (i.e., outside of either of the functions, such...

Why and when there are things I can not do in CLASS SCOPE in C# ?

hi, well... I'm confused about what can I do and what I can't do in CLASS SCOPE. For example ========================= class myclass { int myint = 0; myint = 5; *// this doesnt work. Intellisense doesn't letme work with myint... why?* void method() { myint = 5; *//this works. but why inside a method?* } } ========...

How can an java event listener defined as an anonymous inner class use a variable from an enclosing class?

Here's the code: protected Dialog onCreateDialog(int id) { Dialog dialog = null; if (id == DIALOG_SEARCH) { dialog = new Dialog(this); dialog.setContentView(R.layout.search_dialog_layout); dialog.setTitle("Search Dialog"); Button button = (Button) dialog.findViewById(R.id.Button01); final ...

class scope question in PHP

scope issue in PHP classes: Why does this work? class index extends Application { function ShowPage() { $smarty = new Smarty(); // construct class $smarty->assign('name', 'Ned'); // then call a method of class $smarty->display('index.tpl'); } } $index_inst...

Main() doesn't want to access a class variable

Why I can access to X variable from "method()" and not from Main() method? class Program { int X; // this is the variable I want access static void Main(string[] args) { int a; a = X; // this doesnt work, but why? } void metodo() { int b; ...

Three20 Search Scope

Hey there, I'm using Three20 and I've got the standard search mechanism working. TTTableViewController* searchController = [[[TTTableViewController alloc] init] autorelease]; searchController.dataSource = [[[MyDataSource alloc] init] autorelease]; self.searchViewController = searchController; self.tableView.tableHeaderView = _searchC...

Nested templates with dependent scope

What is dependent scope and what is the meaning of typename in the context of the following error? $ make g++ -std=gnu++0x main.cpp main.cpp:18:10: error: need 'typename' before 'ptrModel<std::vector<Data> >::Type' because 'ptrModel<std::vector<Data> >' is a dependent scope make: *** [all] Error 1 /* * main.cpp */ #include <vector...

JavaScript losing "this" object reference with private/public properties

I have the following error when running the page below: "this.testpublic is not a function" test = function() { var testprivate = function() { this.testpublic(); } this.testpublic = function() { console.log('test'); } testprivate(); } new test(); Apparently w...

Problem porting sudoku solver from C to Python

I recently wrote a sudoku solver in C to practice programming. After completing it I decided to write an equivalent program in Python for a comparison between the languages and more practice and this is where the problem is. It seems to be that a global variable (sudokupossibilities[][][]) I declared outside the while loop isn't availabl...

How can I limit feature visibility in SharePoint 2010?

I have a SharePoint 2010 (farm) solution that contains exactly feature: The feature is site-scoped. The feature's visibility is set to "true". The assembly deployment target is set to "Web Application". The feature contains one webpart. After adding this solution to the solution store I can deploy the solution to a specific web applicat...

Python: Sharing global variables between modules and classes therein.

I know that it's possible to share a global variable across modules in Python. However, I would like to know the extent to which this is possible and why. For example, global_mod.py x = None mid_access_mod.py from global_mod import * class delta: def __init__(self): print x bot_modif_mod.py import mid_access_mod imp...

Why does one Javascript closure work and the other doesn't?

There are two versions, supposedly when the user click the first link, it will alert "1", and the second link, "2", etc: Version 1: <a href="#" id="link1">click me</a> <a href="#" id="link2">click me</a> <a href="#" id="link3">click me</a> <a href="#" id="link4">click me</a> <a href="#" id="link5">click me</a> <script type="text/javas...

which scope (application, servletContext, httpSession) will EL use for interpreting attributes

Hi all, when I use <c:out value="${track}"> in a jsp, where should the attribute track be located in (servletContext, httpSession and request)? I tried to have a controller to set the attribute track to the httpSession, but then ${track} doesn't give me anything in the .jsp. On the other hand, if I set it to the servletContext, ${track}...

Why are my properties `out of scope`?

I have a method to generate some strings based on the values of some variables I get from I picker controller that is presented modally. I get the values back in the delegate method fine and I can assign them to some properties in my view controller successfully. When I call my method to do the updating, I send the values to the consol...