class

[C#] XButton1/2 as global hotkey

I recently stumbled upon a global hotkey class (This one), it works very well and was just what i needed. But i ran into an issue with it, for some reason it doesn't work with the mouse buttons XButton1 and XButton2. So i would like to ask, if there's any way to make it work, or if there's a logical explanation as of why it won't work...

PHP sharing objects, do they get updated in another class?

Hello, I'm wondering; lets say you start an object in a new class; at the beginning of your app. If you later pass that object into another class; as a variable and add/modfiy something on it. Will it be updated in the original object and its home class? Or does it become a 'new' object, a different object in a new class? And will it ...

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() { ...

PHP OOP Cart Class display

Hi, I made an PHP OOP Cart Class like this print_r($_SESSION["cart"]); the result is: Array ( [1] => 1 [3] => 2 ) How can I print this session, like a "real" cart? example: echo "Your basket: "; echo "ItemID: ".$cartid." Itemnumber:".$cartnumber; The adding to basket part: if (isset($_POST['submit'])) { $cart= new Cart(...

Class passing it self

I have a class that creates the object of type Smo. The object then calls a static method from another class. The static method requires that I pass the object to it that is calling it. How do I designate the calling object as the parameter to pass. For example: class Smo { Smo() { } void sponge() { car.dancin...

Class Casting in MooTools?

I have a class and two other classes extending it. I essentially want to be able to make an object of the main class and then be able to convert/cast it into the appropriate subclass depending on some conditions of the object itself. Alternatively, I could replace the instance of the main class with an instance of the subclass. Are eithe...

Create an HTML Class in a PHP Document

Hi all, I'm currently trying dynamically create an html table in PHP. Further, I want the first two lines to be a different color. The solution I see is to give them a class and then use css to color the lines. if ($count<=2){ echo "<tr> class='color'"; }else echo"<tr>"; //other code echo"</tr>"; Problem is my code prints out th...

Using a generic type of a subclass within it's abstract superclass?

Hi there! Within my code a have the following abstract superclass public abstract class AbstractClass<Type extends A> {...} and some child classes like public class ChildClassA extends AbstractClass<GenericTypeA> {...} public class ChildClassB extends AbstractClass<GenericTypeB> {...} I'm searching for an elegant way how I can us...

Understanding Class in ObjectC

in objc.h , there is definition for Class typedef struct objc_class *Class; typedef struct objc_object { Class isa; } *id; Case : use Class in NSObject : /*************** Basic protocols ***************/ @protocol NSObject - (BOOL)isEqual:(id)object; - (NSUInteger)hash; - (Class)superclass; - (Class)class; - (id)self; Hard ...

How to refactor an existing class to become polymorphic?

I have a class that is used as a member in many places in my project. Now, instead of this class I want to have a polymorphism, and the actual object will be created by some kind of factory. I have to choose between: Having to change all the places where I use the class - to call the factory and use a pointer instead of object directl...

HowTo get the class of _ :Any

I've wrapped a Message and would like to log which message I've wrapped. val any :Any = msg.wrappedMsg var result :Class[_] = null The only solution I could find is matching everything: result = any match { case x:AnyRef => x.getClass case _:Double => classOf[Double] case _:Float => classOf[Float] case _:Long => classOf[Lo...

Is the padding between class members of the same type always the same?

The following class contains some members of the same type: template <typename T> class MyClass { T m0; T m1; T m2; T m3; T m4; //... }; The members are all declared without an intervening access-specifier and thus are allocated that later members have higher addresses (ISO/IEC 14882: 9.2.12). The same paragrap...

Any performance reason to put attributes protected/private ?

I "learned" C++ at school, but there are several things I don't know, like where or what a compiler can optimize, seems I already know that inline and const can boost a little... If performance is an important thing (gaming programming for example), does putting class attributes not public (private or protected) allow the compiler to ma...

PHP Class to Calculate GPA

I'm looking for a PHP class or script that i can use the calculate a students GPA from a Grade point scale. Example: http://www.williams.edu/registrar/records/gpa.html Also, need to take into account Honor and AP classes. (If class is chosen as honors assign additional .5 points to letter grade. If chosen as AP or IB assign 1 addition...

Strange class declaration.

In Qt's qrect.h I found class declaration starting like this: class Q_CORE_EXPORT QRect { }; As you can see there are two identifiers after class keyword. How shall I understand this? Thank you. ...

PHP - Strings - Remove a HTML tag with a specific class, including its contents

I have a string like this: <div class="container"> <h3 class="hdr"> Text </h3> <div class="main"> text <h3> text... </h3> .... </div> </div> how do I remove the H3 tag with the .hdr class using as little code as possible ? ...

Base class handle to child class instance. Is there an elegant way to get the child class type at runtime?

This is how I do it currently: ref class Base abstract {}; ref class ConcreteClass1 : public Base {}; ref class ConcreteClass2 : public Base {}; (...and even more...) void DoStuff(Base ^base) { System::Type ^type = base->GetType(); System::String ^name = type->Name; if(name == "ConcreteClass1") DoOtherStuff((Concret...

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...

JQuery selector multi-class objects

Hey all, I've been trying to get a series of objects to appear that have multiple classes associated with them <div class="Foo Bar"> Content </div> <script> alert($('.Foo').length); </script> The selector above is returning 0. This is unfortunately one of those questions that is completely impossible to ask to google (at leas...

In C++ how can you create class instance w call to either a struct or nothing?

I'm creating a Class. This class stores user preferences in a Struct. When creating an instance of the class, I want the client to have the option of creating an instance with no preferences passed in or with a preferences struct passed in. I can do this with pointers, but I wanted to know how I could do it by passing the preferences...