class

How do I dynamically instantiate a class in javascript?

I'm starting out with classes in Javascript and have hit a wall. I've looked all over for a tutorial that goes a little further than simply how to construct a class (usually Animal) then extend the class and have a Method do something (Dog alert('Bark');). I have created a class that I want a user to be able to instantiate (is that the ...

Equivalence Classes LISP

I need to write a program for equivalence classes and get this outputs... (equiv '((a b) (a c) (d e) (e f) (c g) (g h))) => ((a b c g h) (d e f)) (equiv '((a b) (c d) (e f) (f g) (a e))) => ((a b e f g) (c d)) Basically, A set is a list in which the order doesn't matter, but elements don't appear more than once. The function shoul...

Adding functions to Java class libraries

I'm using a Java class library that is in many ways incomplete: there are many classes that I feel ought to have additional member functions built in. However, I am unsure of the best practice of adding these member functions. Lets call the insufficient base class A. class A { public A(/*long arbitrary arguments*/) { //...

PHP Classes: parent/child communication

Hi all, I'm having some trouble extending Classes in PHP. Have been Googling for a while. $a = new A(); $a->one(); $a->two(); // something like this, or... class A { public $test1; public function one() { echo "this is A-one"; $this->two(); $parent->two(); $parent->B->two(); // ...how do i do something...

Cocoa class not displaying data in NSWindow

I have one class that controls one window, and another class that controls a different window in the same xib, however, the second window never displays what it should. In the first class I alloc and init the second class, then pass some information to it. In the second class it displays that data in the table view. Yes, in the .xib I ...

Python New-style Classes and the Super Function

This is not the result I expect to see: class A(dict): def __init__(self, *args, **kwargs): self['args'] = args self['kwargs'] = kwargs class B(A): def __init__(self, *args, **kwargs): super(B, self).__init__(args, kwargs) print 'Instance A:', A('monkey', banana=True) #Instance A: {'args': ('monkey',), ...

When I overload the assignment operator for my simple class array, I get the wrong answer I expect

//output is "01234 00000" but the output should be or what I want it to be is // "01234 01234" because of the assignment overloaded operator #include <iostream> using namespace std; class IntArray { public: IntArray() : size(10), used(0) { a= new int[10]; } IntArray(int s) : size(s), used(0) { a= new int[s]; } int& operator[]( int...

Flash CS3/AS3 - How to Mask Nested MovieClips in External Classes

I have a number of external class files that make up (or are trying to build) a portfolio. One of the class files for this project is a Menu.as class I tried extends, but I'm yet to use extends to where it doesn't become a ball of tangled holiday cheer. So my main portfolio class (the one where I'm assembling everything) calls an instan...

function and class to show image not working in php

i am trying to get get the following working nothing is happen when i use the function i am trying to get it to display images class ItemRes { //items DB var $img=""; } function ShowItemImage($index,$res_a){ if(sizeof($res_a) > $index){ if($res_a[$index] != NULL) { $cimg = $res_a[$index]->img; return "<img src='$cimg' w...

Return Multiple Objects Using ASP.NET MVC'S JsonResult Class....

Is it possible to Multiple Objects Using ASP.NET MVC'S JsonResult Class.... Here is a controller method which returns json object of my records but i also want to pass the count value.... var materials = consRepository.FindAllMaterials().AsQueryable(); var count = materials.Count(); var results = new PagedList<MaterialsObj>(materials, c...

Objects with the same attributes and methods belongs to the same class?

Objects with the same attributes and methods belongs to the same class? Can't I declare two identical classes with the same methods and attributes, instanciate them and have "objects with the same attributes and methods belonging to different classes"? Can't I declare a class A and a sub-class B (children of the class A) both with the ...

Pass in a value into Python Class through command line

Hello, I have got some code to pass in a variable into a script from the command line. I can pass any value into function for the var arg. The problem is that when I put function into a class the variable doesn't get read into function. The script is: import sys, os def function(var): print var class function_call(object): def...

php: two objects from the same class work independent of each other

Good morning, I would like the code in my controller to look something like this: <?php $class = new sanitizeInput() $string1 = $class -> input($_POST[name]) -> mysql_escape(); $string2 = $class -> input($_POST[age]) -> mysql_escape(); print " String1: $string1 <br /> String2: $string2" ?> It seems with my sanitizeInput c...

How to pass a variable from a function to a class python

Hello, I am trying to pass a variable from a function to a class. Example code is below: def hello(var): return var class test(): def __init__(self): pass def value(self): print var hello(var) test = test() test.value() I would like to pass var into the class test(). Thanks for any help. ...

Objective-C Basic class related question, retaining the value of a specific object using a class file

Members, scholars, code gurus. My background is far from any computer programming thus my question may seems basic and somewhat trivial to you. Nevertheless it seems that I can't put my head around it. I have googled and searched for the answer, just to get myself confused even more. With that, I would kindly ask for a simple explanation...

Java Design Questions - Class, Function, Access Modifiers

I am newbie to Java. I have some design questions. Say I have a crawler application, that does the following: 1. Crawls a url and gets its content 2. Parses the contents 3. Displays the contents How do you decide between implementing a function or a class? -- Should the parser be a function of the crawler class, or should it be a clas...

VB.NET Interfaces

I am not quite clear as to why or when to use Interfaces. Can someone post a complete, simple and small example of an Interface using VB.NET in a Console Application. How is it extensible? ...

What happens when I instantiate class in Python?

Could you clarify some ideas behind Python classes and class instances? Consider this: class A(): name = 'A' a = A() a.name = 'B' # point 1 (instance of class A is used here) print a.name print A.name prints: B A if instead in point 1 I use class name, output is different: A.name = 'B' # point 1 (updated, class A itself is...

Clone existing structs with different alignment in Visual C++

Is there a way to clone an existing struct with different member alignment in Visual C++? Here is the background: I use an 3rd-party library, which defines several structs. To fill up the structs, I pass the address of the struct instances to some functions. Unfortunately, the functions only returns unaligned buffer, so that data of so...

Alternatives to persisting objects than using __destruct() in PHP

I usually use a classes destructor method __destruct() to persist objects to session or what have you. It is just very convinient, but I'm curious to if there are any other methods that are equally appealing. Do you know of such? The curiousity arose as I was to merge/utilize two frameworks that both made use of __destruct() for persist...