methods

C++ : Call a base class method automatically ?

Here we go, I'm trying to implement the command design pattern, but I'm stumbling accross a conceptual problem. Let's say you have a base class and a few subclasses like in the example bellow : class Command : public boost::noncopyable { virtual ResultType operator()()=0; //restores the model state as it was before command'...

PHP5.3: "Call to undefined method" error when calling invoke from class variable

I have been doing some tests (to replace old code) with the __invoke magic method and I'm not sure this is a bug or not: Lets suppose we have a class: class Calc { function __invoke($a,$b){ return $a*$b; } } The following is possible and works without any problem: $c = new Calc; $k = $c; echo $k(4,5); //outputs 20 ...

Why is Main method private?

New console project template creates a Main method like this: class Program { static void Main(string[] args) { } } Why is it that neither the Main method nor the Program class need to be public? ...

In Ruby, how do you refer to a function without invoking it, because foo is the same as foo() so it is already invoked

In Ruby, how do you refer to a function without invoking it, because foo is the same as foo() so it is already invoked. for example, puts.class is the same as puts().class ...

What is the required visibility of an action method in iphone responder chain?

In a UIViewController subclass I create a bar button item that fires an event up the responder chain: UIBarButtonItem* editListsButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:nil action:@selector(edit)]; self.navigationItem.leftBarButtonItem = editListsButton; [editListsButton release];...

Declaration of Methods should be Compatible with Parent Methods in PHP

Strict Standards: Declaration of childClass::customMethod() should be compatible with that of parentClass::customMethod() What are possible causes of this error in PHP? Where can I find information about what it means to be compatible? ...

Delphi 6: Force compiler error on missing abstract class methods?

I'm using Delphi Pro 6. Right now, the only way to know if a class is missing a base class abstract method is to wait for the IDE to emit a "constructing instance of {derived class} containing abstract method {base class.abstract method name}" warning or to wait for a runtime Abstract Error method when an attempt to call the missing met...

What's the rationale/history for the # convention of identifying methods in Ruby?

For example, I've always seen methods referred to as String#split, but never String.split, which seems slightly more logical. Or maybe even String::split, because you could consider #split to be in the namespace of String. I've even seen the method alone, when the class is assumed/implied (#split). I understand that this is the way me...

PHP class methods cascading

Hello Geeks I have seen many php scripts in which you can cascade class method to produce a specific functionality for example as in codeigniter when you load a view you would type <?php class Posts extends Controller { function index() { $this->load->view("BlaBla"); } } ?> I am not completely sure ...

Creating methods on the fly

Hi I'm trying to author a jQuery plugin and I need to have methods accessible to elements after they are initialized as that kind of object, e.g.: $('.list').list({some options}); //This initializes .list as a list //now I want it to have certain methods like: $('.list').find('List item'); //does some logic that I need I tried with ...

Method definitions for methods contained in System.Xml.XMLReader

I haven't been able to find a reference that defines what these methods are made up of. I kind of get what these methods do and what arguments they take, but I'm hoping to find out how they work. I'd like to find something that would give me a definition such as void System.Xml.Xmlreader() { //class constructor function } for all or...

When is a return type required for methods in Scala?

The Scala compiler can often infer return types for methods, but there are some circumstances where it's required to specify the return type. Recursive methods, for example, require a return type to be specified. I notice that sometimes I get the error message "overloaded method (methodname) requires return type", but it's not a general...

Is a class instantiated when a static method is called in a non-static class?

Exactly what happens when Foo.SomeCheck() is called in the Bar class? Is an instance of Foo created in order to call SomeCheck()? If so, is this instance stored on the heap, and is it ever collected through garbage collection? public class Foo() { public static bool SomeCheck() { return true; } } public class Bar() { ...

value of the parameter of a method

What will be the value of the parameter i.e. private static boolean ask(int i){int te = 8 + i;} Coz i notice the 'i' was use in the method. I just wonder what will be the value of that 'i' and/or what's the use of it? ...

Javascript method not defined

Why does this not work when I move the code in the first script block (without the script tag itself) to an external javascript file. The idea is to call homead.load() from home page and load everything processed by homead_build(); Error says 'homead not defined' using Firefox Error console <div id="box"> </div> <script type="text/j...

Python: Are class attributes equivalent to local variables when inside a method?

In python, I know that looking up a locally scoped variable is significantly faster than looking up a global scoped variable. So: a = 4 def function() for x in range(10000): <do something with 'a'> Is slower than def function() a = 4 for x in range(10000): <do something with 'a'> So, when I look at a cla...

How can I restrict method calling in the same class ?

Hi All, Recently I attended an interview, the interviewer is asking a question about restricting of method access. Q: In one class I have 3 methods (i.e. method1(), method2(), method3()), I am calling those 3 methods in same class, but I should call only first 2 method, I should restrict 3rd method, so nobody should call method3(). How...

Ruby on Rails - access user defined lib functions in /lib/login_system.rb from app/views/layouts/_menu.rhtml

I have defined a function called is_logged_in? in a user defined library stored in the /lib directory, however when I try to use it in one of my views (in this case a _menu.html.erb view) I get a "undefined method `is_logged_in?' for #" error. I had assumed that if the method was available within the /lib directory then it would be acces...

html method=get not passing values to the next aspx page

i have simple html page with 3 textboxes. <form id="form1" method=get action="http://mysite.com/default.aspx" runat="server"> <div> <input id="name" type="text" value="Amy" /> <input id="email" type="text" value="[email protected]"/> <input id="phone" type="text" value="2125552512" /> </div> <input id="Subm...

How to identify if an object returned was created during the execution of a method - Java

Original Question: Given a method I would like to determine if an object returned is created within the execution of that method. What sort of static analysis can or should I use? Reworked Questions: Given a method I would like to determine if an object created in that method may be returned by that method. So, if I go through and add a...