class

Load method from current Controller

Hi there! I have a problem that I can't figure out. I'm building a small framework (practice) and now I'm building the Validator library. everything works superb except when I trying to fix the "callback" rule. Callback rule is used when the dev need to use a rule that dosen't exists in the Validator lib.. Here's how I'm doing it. In...

c++ templated friend class

Hello all, I'm trying to write an implementation of a 2-3-4 tree in c++. I'm it's been a while since I've used templates, and I'm getting some errors. Here's my extremely basic code framework: node.h: #ifndef TTFNODE_H #define TTFNODE_H template <class T> class TreeNode { private: Tre...

C++ returning nested class with template on base class problem

I am trying to create a list object, with the iterator class nested inside to understand how it works. In some method, I am trying to return an iterator object but it doesn't work. I created an example to show the problem : // CLASS A template <class T> class A { public: class B; A(){} }; // CLASS B template <class T> cla...

Classical vs Prototypal... how are they so different?

for example in PHP class foo{ function foo($name){ //constructor $this->name=$name; } function sayMyName(){ return $this->name; } } class bar extends foo{ function sayMyName(){ return "subclassed ".$this->name; } } And in JS function foo(name){ this.name=name; } foo.prototype.sayMyName=function(){return th...

jquery: get elements by class name and add css to each of them

Hello, I have a certain number of div boxes that all have the same class name. I am trying to apply something to them all but have no luck. The code I constructed so far is $(document).ready(function(){ elements = $('div.easy_editor'); elements.each(function() { $(this).css("border","9px solid red"); }); //elements[0].css("...

Namespace and classes in php

Why i receive error? the class in the same namespace.. php 5.3.0 namespace ExampleSystem\Core; class Test { public function __construct() { print 'Test ok'; } } // Fatal error: Class 'Test' not found in ... $class_name = 'Test'; $obj = new $class_name; // Ok $class_name = 'ExampleSystem\Core\Test'; $obj = new $class_name...

Javascript Pseudoclass handling in php

Hi all! I am working with javascript pseudoclasses in the sense of: class Foo ---->getName() ---->setName() ---->.... So i can have collections of them to operate with in client calculations. But, there is some way to handle them "as is" in php? in other words, pass it like an object where I could do a call to getName, for example. ...

Reference and Overwriting

I have: class A{ public $name = 'A'; public $B; public function B_into_A($b) { $this->B = $b; } } class B{ public $name = 'B'; public $A; public function new_A_into_B($a) { $this->A = new $a; } } $a = new A; $b = new B; $a->B_into_A($b); $b->new_A_into_B('A'); Is this a goo...

Is there a way to force a classloader to load a package even if none of its classes have been loaded?

Let's say a java codebase has a package called "com.example". At runtime, we can get this Package by calling Package p = Package.getPackage( "com.example" ); //(returns null) or even get a list of all packages by calling Packages[] ps = Package.getPackages(); The problem is - if the ClassLoader has not yet loaded any class from th...

Lifting class instance in Haskell

Is there a way to "lift" a class instance in Haskell easily? I've been frequently needing to create, e.g., Num instances for some classes that are just "lifting" the Num structure through the type constructor like this: data SomeType a = SomeCons a instance (Num a)=>Num SomeCons a where (SomeCons x) + (SomeCons y) = SomeCons (x+y)...

Using super with a class method

I'm trying to learn myself the super() function in Python. I though I got a grasp of it untill I came over this example (2.6) and found myself stuck. http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#super-with-classmethod-example Traceback (most recent call last): File "<stdin>", line 1,...

Extending the MySQLi class

I want to be able to make classes which extend the MySQLi class to perform all its SQL queries. $mysql = new mysqli('localhost', 'root', 'password', 'database') or die('error connecting to the database'); I dont know how to do this without globalising the $mysql object to use in my other methods or classes. class Blog { public funct...

Programs to make class diagrams?

Hi, I know that visual studio has a class diagram designer built in, but I wondered if anybody knew of some other programs that are suitable for making class diagrams? Thanks! ...

Php abstract class site configuration

Hi, i have a config class which is an abstract class. I would like to set it up so it automatically detects which server the site is on and then assigns appropriate constants. I get an error on line ten $this->hostName = $_SERVER['SERVER_NAME']; expecting `T_FUNCTION. What is the correct way to do this and is there a better way to do thi...

JavaScript Classes and Variable Scope

I'm relatively new to JS and I'm having issues properly emulating OOP principles. I guess I have two questions. Question the first is regarding the many ways to declare variables. Say I have a class: function clazz(a) { this.b = 2; var c = 3; this.prototype.d = 4; // or clazz.prototype.d = 4? } var myClazz = new clazz(1)...

Use LINQ generated classes directly?

LINQ will generate a set of classes from the SQL files. Should these be used directly, or should they be wrapped in another class so the model is not so dependent on the implementation? ...

DataTables and custom types

I created a class called CustomData which uses another one called CustomOptions as one of its fields. I want to use the CustomData in a DataTable as values. Here's a short overview (simplified, the fields are private and the accessors public, mostly readonly and the set is done by custom methods); enum CustomDataOptionType { // Some va...

How to check programatically if a type is a struct or a class?

I think the question is clear. ...

C#: Are struct members more performant?

On a blog entry, Luca Bolognese ponders this idea about structs vs. classes as member fields: The reason to use a struct is to not allocate an additional object on the stack. This allows this solution to be as 'performant' as simply having coded the fields on the class itself. Or at least I think so ... How accurate is th...

Using Singletons in PHP

I want to use a DB Singleton i created, in several Methods of a Class. Is it more appropriate to Instantiate the Singleton individually in each Method, or to Instantiate it through the __constructor() and access it from a variable in each method? Thanks. ...