class

How can I read Database Tables with Attributes

Hi all, I want to read database tables with Attributes. I have Table in database and I have class same fields name. I want to transfer to my class which matched values in database using attributes. For Example : [ReadDBAttributes] public class News{ public string Title; public string Content; } How can i do? ...

Best practices for an API in PHP : functions, or classes ?

Hi, In my company we have developped some applications. We have to create an API for one application (say application A), so that the others can use it (an its data). The question is : we already have developped PHP classes for the model of Application A, if we want to create an API, should we : - re-use these classes (too much functio...

How do you make a nested class that can access the members of the class that created it?

Im programming in C#.NET. I want to create a nested class that can access members of the instance that created it but I can't seem to figure out how. This is what I want to do: Car x = new Car() x.color = "red"; x.Door frontDoor = new x.Door(); MessageBox.Show(frontDoor.GetColor()); // So I want the method GetColor of the class Fron...

PHP - Initiate SoapClient inside a SoapServer class function?

So I have a SoapServer class that handles whatever functions is requested of it from the client. Within one of those functions I need to call a 3rd party soap service, so I set about getting what I need as a SoapClient and returning the result back to my SoapServer. Here's a copy of the stack trace: ReadCategories Respsonse:SoapFault ex...

How do I create a list or set object in a class in Python?

For my project, the role of the Lecturer (defined as a class) is to offer projects to students. Project itself is also a class. I have some global dictionaries, keyed by the unique numeric id's for lecturers and projects that map to objects. Thus for the "lecturers" dictionary (currently): lecturer[id] = Lecturer(lec_name, lec_id, ma...

Going from Java imports to C++ includes

I've been struggling with understanding how C++ classes include other classes. I'm guessing this is easier to understand without any preconceived notions. Assume my two classes are Library and Book. I have a .h and .cpp file for each. My "main.cpp" runs a simple console app to use them. Here is a simple example: //Library.h #ifn...

Which jQuery plugin animates an element by sliding it across the page to a 'target' element?

Hay, I'm looking for a jQuery plugin which i've seem before but can't now find it. It animates a div and makes it look like it is being sent to another div, imagine that you click 'buy' on an item and the item appears to moved across the screen to a shopping basket. Any ideas what it is? ...

Getting info about invoking class

Hello everybody. Is it possible to get information about class that invoking the other one? class Bar{ public Bar{} public String getInvokingClassInfo(){ return "..."; } } class Foo{ public Foo(){ Bar bar = new Bar(); System.out.println("Invoking class is: "+bar.getInvokingClassInfo()); } } ...

How do I make a class that can create an instance of another class and access private members of the owner.

I am not sure if what I want to do breaks Object oriented guidelines or not so I will explain what I am doing and hopefully you guys can show me a better way if I am wrong. I tried asking this question before but I gave a poor example so I think it just caused more confusion. So I have a main class, USBCommunicator. The constructor take...

How to implement the Countable interface in PHP?

So that count($object) will return the number of records in it ...

Forwarding method calls to a method with a different signature in Objective-C?

I am trying to implement a JSON-RPC solution, using a server connector object wich obtains a list of available functions from a server somehow like NSDictionary *functions = [server callJSONFunction: @"exposedFunctions" arguments: nil]; wich is a simplified description, since callJSONFunction actually triggers an asynchronous NS...

Delphi 7: Select certain items of a TList

In Delphi I have an own class which is based on TList. It is TPetList. Every instance of TPetList can have some items of the class TPet. The instance of TPetList is displayed in a TListView component using a for loop. TPet is based on TObject and has the following fields: city age breed Now I have a list of checkboxes where the user...

Why can't I call specific class methods on an Iterator?

ArrayList array = new ArrayList(); Iterator it1 = array.iterator(); while (it1.hasNext()){ Myclass temp = it1.myGetterMethod(); System.out.println (temp); } This is what I would like to implement, but Iterator only returns a generic Object. When I call Object.getClass(), the class is Myclass. Does this mean that the Iterator is ...

How to properly instantiate classes in Haskell?

Trying to create a base class from which I can derive different types. What's wrong with the following? class (Eq a) => MyClass a data Alpha = Alpha instance MyClass Alpha where Alpha == Alpha = True I get the error: test.hs:5:10: `==' is not a (visible) method of class `MyClass' Failed, modules loaded: none. ...

retrieving the keys of all variables on an object

If I had: class A(object): varA = 1 inst = A() Then how would I retrieve the keys of all variables on inst? I'd want something like ["varA"] So far, I've gotten this: vars(inst.__class__).keys() #returns ['__dict__', '__weakref__', '__module__', 'varA', '__doc__'] I'm fine with that, I'd just ignore the double-under vars. My ...

C# Create class instance from string

I have a C# method which creates a new instance of a class from a string, however, I get an error when running the code. obj = (ClassX)Activator.CreateInstance(Type.GetType("classPrefix_" + className)); ArgumentNullException was unhandled Value cannot be null Parameter name: type Any help on this error would be apprecia...

Assignment vs Initialization in C++

I thought that constructors control initialization and operator= functions control assignment in C++. So why does this code work? #include <iostream> #include <cmath> using namespace std; class Deg { public: Deg() {} Deg(int a) : d(a) {} void operator()(double a) { cout << pow(a,d...

Python class methods

In Python, which is the best way (style wise) to allow public access to an object's variables? There are lots of options I've seen from different languages, I was wondering which of these (if any) is the preferred Python method? These are the options I'm currently torn between: Allow direct access to object variables (e.g. print(objec...

Create a PHP Class -> Create an object of it in another class

I have created a PHP class called formChecker.php. It validates a form. As a Java programmer, I would like to stick with the idea of creating an instance of this class in another class and run it from there. It doesn't seem to be working for me.The following is a demonstration: class formChecker{ ..... validation functions go here }...

.Net: What does it mean? Having a non-static class with a static method?

What does it mean? Having a non-static class which has for example one static method? Without creating an instance of that class, we can't use it. But What about its static method? ...