class

jQuery's attr - return multiple classes not just the 1st.

Given a div such as: <div class="widget block dock clock">yada yada</div> I'd like to be abe to use JQUERY's $(div).attr('class'); to find all the classes, but the JQUERY.attr only return widget. Is there a way with JQUERY to return all the classes defined for the element? Thanks ...

Calling a function within a class

I am having trouble calling a specific function within a class. The call is made: case "Mod10": if (!validateCreditCard($fields[$field_name])) $errors[] = $error_message; break; and the class code is: class CreditCardValidationSolution { var $CCVSNumber = ''; var $CCVSNumberLeft = ''; var $CC...

Advice/suggestions for my first project PHP Classes

Hi guys, Any advice is welcome! I have a very limited understanding of php classes but below is my starting point for the route I would like to take. The code is a reflection of what I see in my head and how I would like to go about business. Does my code even look ok, or am I way off base? What are your thoughts, how would you go ab...

how do i get change to div id to wait until next image is loaded

I am building a website where I need to change the div class that contains image in order to manipulate the style of the next image given it is different in size and needs to be handled differently. I have a manual slideshow system working with an array of images and an array of corresponding class names. The problem is that the javasc...

python create object and add attributes to it

Hi, I want to create a dynamic object (inside another object) in python and then add attributes to it. I tried: obj = someobject obj.a = object() setattr(obj.a, 'somefield', 'somevalue') but this didn't work. Any ideas? edit: I am setting the attributes from a for loop which loops through a list of values. e.g. params = ['attr1'...

How do I write a writer method for a class variable in Ruby?

I'm studying Ruby and my brain just froze. In the following code, how would I write the class writer method for 'self.total_people'? I'm trying to 'count' the number of instances of the class 'Person'. class Person attr_accessor :name, :age @@nationalities = ['French', 'American', 'Colombian', 'Japanese', 'Russian', 'Peruvi...

C++ Beginner - 'friend' functions and << operator overloading: What is the proper way to overload an operator for a class?

Hello, everyone! In a project I'm working on, I have a Score class, defined below in score.h. I am trying to overload it so, when a << operation is performed on it, _points + " " + _name is returned. Here's what I tried to do: ostream & Score::operator<< (ostream & os, Score right) { os << right.getPoints() << " " << right.scoreGetN...

Getting the compiler to perceive << as defined for a specific class

Hello everyone. I edited a post of mine with this question, yet got no answers. I overloaded << for a class, Score (defined in score.h), in score.cpp. ostream& operator<< (ostream & os, const Score & right) { os << right.getPoints() << " " << right.scoreGetName(); return os; } (getPoints fetches an int attribute, getName a string ...

How do I determine which methods are used by a Java class

I need to provide a report of which APIs are used by our code, and exactly which methods are called. For a Windows DLL, I would use "dumpbin /imports" - is there an equivalent for a Java .class file? javap seems to be the obvious place to look, but I can't find any options that seem to do what I'm after. ...

nesting classes in php

here is my sample class to why i want to nest. include("class.db.php"); class Cart { function getProducts() { //this is how i do it now. //enter code here`but i dont want to redeclare for every method in this class. //how can i declare it in one location to be able to use the same variable in every method? $db = new mysqlDB; $que...

Abstract Base Class or Class?

For my semester project, my team and I are supposed to make a .jar file (library, not runnable) that contains a game development framework and demonstrate the concepts of OOP. Its supposed to be a FRAMEWORK and another team is supposed to use our framework and vice-versa. So I want to know how we should start. We thought of several appro...

javascript class calling XMLHttpRequest internally, then handling onreadystatechange

this thing almost works: function myClass(url) { this.source = url; this.rq = null; this.someOtherProperty = "hello"; // open connection to the ajax server this.start = function() { if (window.XMLHttpRequest) { this.rq = new XMLHttpRequest(); if (this.rq.overrideMimeType) this.rq.overrideMimeType("text/xml"...

C++, class as parameter to a method, not template.

So, I came across an interesting method signature that I don't quite understand, it went along the lines of: void Initialize(std::vector< std::string > & param1, class SomeClassName * p); what I don't understand is the "class" keyword being used as the parameter, why is it there? Is it necessary to specify or it is purely superficial?...

(C++) What's the difference between these overloaded operator functions?

What is the difference between these two ways of overloading the != operator below. Which is consider better? Class Test { ...// private: int iTest public: BOOL operator==(const &Test test) const; BOOL operator!=(const &Test test) const; } BOOL operator==(const &Test test) const { return (iTest == test.iTest); } ...

can i quickly run entire page's text through a function on page load?

i have setup a profanity filter with bad words in a XML file and have the following function to run on my page to replace the words: BadWordFilter.Instance.GetCleanString(TextBox1.Text); i'm about to go through my entire site now wrapping that function around every little text variable one by one and it's going to be a huge pain in the...

how to run if(!User.IsAuthenticated) or access Profile.values in App_Code? c# .NET

i'm trying to run a conditional statement in a class i'm placing in my App_Code folder the condition is whether the person is logged in or not. I normally have two ways to do this in my masterpage and ASPX's if (!User.IsAuthenticated) or if(Profile.username = "anonymous") however neither of these things seem available to me in the .cs...

Class lookup structure array in C++

I'm trying to create a structure array which links input strings to classes as follows: struct {string command; CommandPath cPath;} cPathLookup[] = { {"set an alarm", AlarmCommandPath}, {"send an email", EmailCommandPath}, {"", NULL} }; which will be used as follows: CommandPath *cPath = NULL; string input; getline(cin, i...

Handle order dependence in loops

Hey all, I'm making a templating system where I instantiate each tag using a foreach loop. The issue is that some of the tags rely on each other so, I'm wondering how to get around that ordering from the looping. Here's an example: Class A { public $width; __construct() { $this->width = $B->width; // Undefined! Or atleast not...

Java interface and abstract class issue

Hello everyone, I am reading the book -- Hadoop: The Definitive Guide In chapter 2 (Page 25), it is mentioned "The new API favors abstract class over interfaces, since these are easier to evolve. For example, you can add a method (with a default implementation) to an abstract class without breaking old implementations of the class". Wh...

Using $this when not in object context

I'm creating a function to show blog's. So I made a show blog function but it keeps giving "Using $this when not in object context" error Class Blog{ public function getLatestBlogsBig($cat = null){ $sqlString = "SELECT blog_id FROM jab_blog"; if($cat != null) $sqlString .= " WHERE blog_cat = " . $cat; ...