class

Native Javascript Class implementation

Hi, I am involved in a web application project at the moment and we are not going to be using a framework. I am looking for the 'best' javascript inheritance implementation. I have worked with prototypal style classes as follows: function animal(options) { self = this; //properties this.name = options.name; //eve...

Getting the name of a sub-class from within a super-class.

Let's say I have a base class named Entity. In that class, I have a static method to retrieve the class name: class Entity { public static String getClass() { return Entity.class.getClass(); } } Now I have another class extend that. class User extends Entity { } I want to get the class name of User: System.out.pri...

Prevent Rails 2 from caching of Lib/ Classes

Does anyone know how to instruct rails to NOT cache classes that are included within the lib folder? ...

Am I starting down a C# bad practice path, creating individual classes for an activity log?

I have a web app that contains an activity log for actions the users take. There are multiple types of activities that can be logged. Here's an example: public static class NewAccountActivity() { public static Write(string username) { //... do stuff to enter a new account activity into the database ... } } public static class N...

Rails - Refer to current object in model

I must admit, I am not even sure if I put the question right... In my app I have a bunch of named scopes to build more efficient finds. The one that I can't get to work is this: => I want to find all products in the current category and its descendants. I use the 'ancestry' gem to build the tree, and it provides named scopes on the Cla...

Share instance data across objects/classes in a custom web app

I'm working on a rack web app from the ground up in Ruby and I want to be able to share the instances of several objects across all classes in the app. For example, the logger, the request information, a currently authenticated user, get/post parameters, etc. To any of you familiar with PHP, I've accomplished this in the past with stati...

Child class as return type for a class method.

I have a C++ class which is meant to be inherited. All its children will inherit a method: class Record { public: RETTYPE* all(); }; class Child : public Record { int age; char *name; }; int main() { Child boo; Child boos* = boo->all(); // Pointer to array of Children return 0; }; How can I make a method retu...

Calling php classes from other files

I am working on some custom post types. I finished the first one and realized that the metabox code I was using could be re-used by other, future, custom post types (as well as pages, posts, etc). So I put the class in its own php file and included it from the functions.php file of my child theme. I've never used classes before, but I...

Iterator member behavior

I was expecting the second assert in the following to pass. I'm asking for your help. Edit: It didn't work when I had poss everywhere instead of poss_a in some places. #include <vector> #include <cassert> class Sampler { public: std::vector<int*> poss; std::vector<int*>::const_iterator poss_it; Sampler(std::vector<int*> poss_a) : ...

In Flash, how do I import a package, instantiate the class, and call a method without getting an error?!

This is driving me absolutely nuts. I've scoured threads on the subject and NOTHING seems to work. I have an FLA file with the following code on frame 1: import TestClass; var tstClass:TestClass = new TestClass; tstClass.testMethod(); In the accompanying AS file, I have the following: package { public class TestClass { ...

Using jQuery to assign an active class to an area tag (image map)

Is there a way, through jQuery, to assign an active class to an area tag within an a map? I have a bunch of areas defined like this: <map name="mappy"> <area shape="rect" coords="162,105,179,136" href="#" title="Unique Title 1" alt="Unique Title 1" /> <area shape="rect" coords="205,72,222,101" href="#" title="Unique Title 2" ...

Listing classes in a jar file

Hi every one! How can I dynamically load a jar file and list classes which is in it? ...

class and struct in c++

Possible Duplicate: What are the differences between struct and class in C++ what is the practical difference between class and struct in c++ except the default definition of members to be public (in struct) and private (in class)? if this is the only difference why do we need both? ...

Is there a way to have a class evaluate as a number?

i have a python class like so: class TAG_Short(NBTTag): def __init__(self, value=None): self.name = None self.value = value def __repr__(self): return "TAG_Short: %i" % self.value This tag is filled out at runtime, but i'd also like to be able to use it like: mytag = TAG_Short(3) mycalc = 3 + ( mytag ...

C++ / Qt : passing variables to be changed in the class

Hello, So I have two forms in my project: MainWindow and Options Form (OptForm; QWidget); Now, I create (simply dragging to a form) a QPushButton in MainWindow to open OptForm, and passing in variables, which OptForm can change. void MainWindow::openOpt() //Slot; QPushButton calls(?) it { OptForm w (this->variable1,this->variable2,...

PHP include outside class only Once

I'm a new guy in PHP OOP concepts. One of the first things that caught my eye that I can't include a php script to multiple classes just by writing it once at the begining of the script. I mean <?php include 'var.php'; class userSession{ /* all the code */ public function getVariables(){ /* use of variables which are inside var.p...

How can I return a value from a class object?

Is it possible to have a class object return a true/false value, so I can do something like this: MyClass a; ... if (a) do_something(); I can accomplish (almost) what I want by overloading the ! operator: class MyClass { ... bool operator!() const { return !some_condition; }; ... } main() MyClass a; ... i...

Accessing a class's variable in Python

class Example(object): def the_example(self): itsProblem = "problem" theExample = Example() print(theExample.itsProblem) How do I access a class's variable? I've tried adding this definition: def return_itsProblem(self): return itsProblem Yet, that fails also. ...

Accessing Ruby Class Variables with class_eval and instance_eval

I have the following: class Test @@a = 10 def show_a() puts "a: #{@@a}" end class << self @@b = '40' def show_b puts "b: #{@@b}" end end end Why does following work: Test.instance_eval{show_b} b: 40 => nil But I can't access @@b directly? Test.instance_eval{ @@b } NameError: uni...

Python : Allowing methods not specifically defined to be called ala __getattr__

Hi, I'm trying to write a Python class that has the ability to do the following: c = MyClass() a = c.A("a name for A") # Calls internally c.create("A", "a name for A") b = c.B("a name for B") # Calls internally c.create("B", "a name for B") A and B could be anything (well, they're defined in a database, but I don't want to explicitly...