class

Unique ID and multiple classes with XPath

Hi I'm using XSLT for displaying a ul menu containing li and a. I want the following: Find the first li a element and add the .firstitem class. Find the last li a element and add the .lastitem class. Find the active li a element and add the .active class. Add an unique ID to each li a element. (I.e. URL friendly menu text as ID). I...

initalize boost::multi_array in a class

Hi to all, for start i would like to say that i am newbie. i am trying to initialized boost:multi_array inside my class. I know how to create a boost:multi_array: boost::multi_array<int,1> foo ( boost::extents[1000] ); but as part of a class i have problems: class Influx { public: Influx ( uint32_t num_elements ); bo...

Find tags with no classes and add a class

Hi I need jQuery to add a class to any form element that has no class allready. I made up a function, the hasNoClass. Is it possible to do in the real life? Pseudo code: add class to "classless" form tag jQuery("form").hasNoClass().addClass("gotClass"); Alternatively it can be done by a "add class to 3rd form start tag on page. No clu...

Groovy / Grails - How to get class instance from String?

I'm trying to derive the class instance of a groovy class from the name of string. For example, I'd like to do some code along these lines: def domainName domainName = "Patient" // but following line doesn't work, domainName is a String def domainInstance = domainName.get(1); ...

Utilizing objects in another class in Python

In code(pseudo) like this def path(): dirList = ['c:\\', 'y:\\', 'z:\\'] home_folder = 'peter.txt' complete = [s + home_folder for s in dirList] print complete def fileWrite(): filename = 'c:\peter.txt' text = 'Hello World' file = open(filename, 'w') file.write(text) file.close() I can make both wo...

In C#, can a class inherit from another class and an interface?

I want to know if a class can inherit from a class and and interface. The example code below doesn't work but I think it conveys what I want to do. Does anyone have any recommendations??? The reason that I want to do this is because at my company we make USB, serial, Ethernet, etc device. I am trying to develop a generic component/inte...

C++ object class problems when used in another class

Having trouble when trying to create a class using another class(and 2 inner classes), I think it might be a syntax problem. The first class class listitem { //listitem.h(11) public: //MONSTER CLASS static class monster { public: monster(string thename); monster(void); ~monster(void); privat...

How to run database class methods inside other classes?

I am new to using classes in PHP, I just realized, in most of my class methods, I need to do some mysql queries. I have another class that handles my connection and queries but how should I go about calling that class from other classes? Doesn't this kind of defeat the purpose of using classes if all my classes rely on my DB class? ...

private members in python

how can i make a methods and data members private in Python? Or doesn't python support private members?? ...

How to define a common variable in javascript Class that can be used across instances?

I want to define a single variable used among all instances in the Class definition(which is a plain function constructor in a jQuery plugin). Is there such a feature? If there is,just a simple demo and I think I'll understand. ...

Easiest way to make C# not instantiate a class unless inherit?

What is the easiest way to make C# not instantiate a class unless inherit? Sounds weird but i dont want to explain the why. I have a base class and two class that inherit it. I want to use the derived class only and not the base. The derive class does not have any extra functions. Whats the easiest way to NOT allow me to write new BaseC...

What is the best way to pass or access other objects in other classes in PHP?

I need some help in planning out how to do my classes in PHP. I have a session class and a database class that I pretty much need to access inside of every other class I use (forums, mail, users, lots more classes) So I am looking for how I should access the session class inside of my other classes, 1 option is to make it GLOBAL, ano...

Best way to 'convert' a shared base ?

-edit- Jason makes a good point that i could add both types to a list of A. But i cant use A due to reflections. Thus i want to know a way to convert the base data from one derive to another. I know in C++ in certain cases i could simply do *(A*)this = (A)that. I am hoping there is something just as simple in C#. I seriously do have the...

Copy a class to another?

I have class A { public int a; public string b; } How can i copy A to another A? In C++ i know i could do *a1 = *a2;. Is there something similar in C#? I know i could write a generic solution using reflection but i hope something exist already. I'm considering changing A to a nullable struct. Step 2 i'll need to do class B ...

c# Mocking Interface members of a concrete class with Moq

I have an interface ITransaction as follows: public interface ITransaction { DateTime EntryTime { get; } DateTime ExitTime { get; } } and I have a derived class PaymentTransaction as follows: public class PaymentTransaction : ITransaction { public virtual DateTime LastPaymentTime { get {...

Java seperate MouseListener and performance

Hi all, writing a game and using mouse events for the first time, but as i play with them, the various methods are getting bigger, i want to seperate the listening stuff into a diffrent class, but i will still need acsess to my various objects that are stored in my main class (where the listener methods currently resides having used imp...

Identifying derived types from a list of base class objects

This may seem kind of "homework-ish" and/or trivial, but it is for a real business purpose; it's just the easiest way I could think of to explain what I'm conceptually trying to do. Suppose I have an Animal class, and some other classes (Bird, Cat, Kangaroo). Each of these inherits from Animal. Animal might look like this: public cl...

General Objective-C Class method question

I have an iPhone application which has some methods to gather information from the web and which then creates an object, which holds this information as properties (lets say I'll get objects of type x). Since I might need those kind of objects from various points within the application, I put the method to create one instance of the obje...

PHP Access sub property by name at runtime

Hello! Is it possible to access a sub-property of an object dynamically? I managed it to access the properties of an object, but not the properties of a sub-object. Here is an example of the things I want to do: class SubTest { public $age; public function __construct($age) { $this->age = $age; } } class Test...

Cannot Modify Non Const Member in Class

Hi, I try to modify one specific method in OpenCV. In the class definition; class CV_EXPORTS CvANN_MLP : public CvStatModel ... protected ... int activ_func; when I try to modify activ_func field, I get: error: assignment of data-member in read-only structure error, however it is not defined as const, how is that possible? ...