class

Python newbie having a problem using classes

Im just beginning to mess around a bit with classes; however, I am running across a problem. class MyClass(object): def f(self): return 'hello world' print MyClass.f The previous script is returning <unbound method MyClass.f> instead of the intended value. How do I fix this? ...

Two classes and inline functions

I have two classes and both of them uses some of the other class, on example: // class1.h class Class1; #include "class2.h" class Class1 { public: static Class2 *C2; ... }; // class2.h class Class2; #include "class1.h" class Class2 { public: static Class1 *C1; ... }; And when I define it like in example above, it works ...

C++ help (Bisection/Newtons Method)

I need to write a class that includes a bisection and newton function. I understand how each method works, I just need to know how to write a class that passes the parameters of each function correctly. Parameters: Bisection The function you're finding the root of the starting interval (a,b) the absolute tolerance the relative...

In javascript, how do I call a class method from another method in the same class?

I have this: var Test = new function() { this.init = new function() { alert("hello"); } this.run = new function() { // call init here } } I want to call init within run. How do I do this? ...

overriding bool() for custom class

All I want is for bool(myInstance) to return False (and for myInstance to evaluate to False when in a conditional like if/or/and. I know how to override >, <, =) I've tried this: class test: def __bool__(self): return False myInst = test() print bool(myInst) #prints "True" print myInst.__bool__() #prints "False" Any sugg...

Problem with Inner Class. Illegal Start of Expression error

Hi, I am practicing using inner classes but am having difficulty with a homework question: It is as follows: Create a Swing component class BetterButtons that extends JPanel and has three Jbutton instances labelled "One", "Two", and "Three". In the constructor of BetterButtons, write a local class ButtonListener that implements Action...

Changing classes in jQuery only works the first time I click

To all the jQuery guru's out there I could use your help pointing out what is probably a silly error on my part. I'm trying to swap classes onclick when the user clicks on a div with the hotspot class. The code below swaps the class the first time I click but not the second and subsequent times. Also if there's a cleaner way to accomplis...

What is the scope of methods and properties of classes within App_Code in a web site project?

hi First, sorry for poor english writing . If I declare a for example property or enum in a class of App_Code, then what is the scope of that property? ...

jquery show / hide div on click?

I'm trying to use jquery to show and hide a div onclick, and, although I'm not getting any errors, it's not showing or hiding anything either. *EDIT - UPDATED * $(document).ready(function() { $("#nav-inner a").click(function() { var type = $(this).attr("class"); $("div.v1 > div").not("." + type).st...

How can I concatenate a constant and a variable and store it in a class constant with PHP?

class My_class { const STATUS_ERROR = 0; const STATUS_OK = 1; const DB_TABLE = TABLE_PREFIX . 'class_table'; } The two status consts work fine and can be accessed within class methods as self::STATUS_ERROR and self::STATUS_OK just fine. The issue is one of how to stop the following error being thrown when I try to define th...

How to declare a javascript class with short function names and assign later to a long class name?

Let me explain, this is about displaying class source code in IDEs. I have always only one class per file. A class is declared like this in the file mod1.js: MYGLOB.MOD1.ClassXy = function () { //constructor, do somothing } MYGLOB.MOD1.ClassXy.prototype.memberfunc1 = function () { //member function 1, do somothing } (There are ma...

[PHP] Unset Class

Hello Guys, i have a complete Form creation System. There are many different Question Types and I have to check if the answer which the person had made is correct. All types of Questions has its own class will is always called ItemClass and this Class is in its own File. Everytime a Question is asked I include the File and the there is...

Getting the instance that called the method in C#

I need to have an algorithm that can get the object a method within the method like this: public class Class1 { public void Method () { //the question object a = ...;//the object that called the method (in this case object1) //other instructions } } public class Class2 { public Class2 () { ...

ASP.Net C# ResolveClientUrl inside Class

Hi, I have the following code: public class NavigationPath { private string menuItems = "<li>" + "<a href=\"#\">home</a>" + "</li>"; But I would like to have: public class NavigationPath { private string menuItems = "<li>" + ...

Best Practice: How to Insert into Multiple Tables Through the Business Layer and Data Layer?

I USED to be a developer and part-time db designer, but it's been many years and I'm re-learning... I'm building a web app and have a Person (actually "Profile") table with a number of child tables which have N:N relationships with my Person table, e.g. FavoriteSports MusicalInstruments ArtisticSkills After reading through Scott ...

Drupal API: how to load a module dependency from another module

I am attempting to develop a Drupal module that defines the class MyFeedsSyndicationParser. This class extends the class FeedsSyndicationParser from the Feeds module. In my module's .info file the dependency on the Feeds module is identified. When I enable the module the php_error.log contains: PHP Fatal error: Class 'FeedsSyndication...

OOP functionname acting as __construct when its the same name as the class

Bit long title, comes down to this: <?php class error { public function error($errormsg = false, $line = false) { echo 'errormsg: '.$errormsg.' on line: '.$line; } } ?> When i call this class in another file, with for example: <?php $error = new error; ?> It already execut...

How do I modelize my two classes knowing one needs the method of the other?

Hello, I have these two classes and the class Retrodoc needs to know the versionPath() to execute its method run($versionId). So what is the best modelization? Do I instanciate Version in the method and then I can use the method getVersionPath()? Thanks in advance. ...

How can i add property to a class dynamically

Hi there, I want to create an error class. And it has some static properties. For example : Message, InnerException, Stacktrace, Source. But i want to add some dinamiclly properties. If exception is a FileNotFoundException, i want add FileName property. Or if it s a SqlException, want to add LineNumber property. And i cant inherit that ...

How to find where implementation of a function is located in PHP in this case?

Hello, I was just traversing the workflow of zend framework and cant really find where the function "findByUri()" is located, I found the class it belongs , simply dumping it, but going through the hierarchy of that class(parents , interfaces and so forth) I cant really find it. I found where it is called from .... call_user_func_arra...