class

What's wrong here? - ISO C++ forbids declaration of 'Circle' with no type...

Hey guys, maybe you can help me get this right. I have a class that is used to draw a circle, but the compiler sends me this message: In file included from ./Includes.h:19, from ./Circle.h:8, from ./Circle.cpp:5: ./GameApp.h:24: error: ISO C++ forbids declaration of 'Circle' with no type ./GameApp.h:24:...

Best way to load module/class from lib folder in Rails 3?

Since the latest Rails 3 release is not auto-loading modules and classes from lib anymore, what would be the best way to load them? From github: A few changes were done in this commit: Do not autoload code in *lib* for applications (now you need to explicitly require them). This makes an application behave closer to an engine (code...

Java - Get reference to a static class using reflection

In Java, is it possible to access an instance of a static class (nested) using reflection? Supposing I have the following 2 classes defined in the package Package1.SubPackage.SubSubPackage: public class MyMainClass { public static class SalesObjectGrouper1 { public static final GrouperContext CONTEXT = new GrouperContext("...

Using Python class as a data container

Sometimes it makes sense to cluster related data together. I tend to do so with a dict, e.g., self.group = dict(a=1, b=2, c=3) print self.group[a] One of my colleagues prefers to create a class class groupClass(object): def __init__(a, b, c): self.a = a self.b = b self.c = c self.group = groupClass(1, 2, ...

Jquery, some objects in class animation

I'd like to do search animation like on twitter.com It means that when the user put the cursor over one element some other will be animated also. I try to do it in that way: $(".classinput").mouseover(function(){ $(this).animate({ opacity: 1, }); }).mouseleave(function(){ $(this).animate({ opacity: 0...

Adding a new class to the page using jQuery

I am trying to programatically add a DIV with the class of error_icon to the page using jQuery. This is the HTML: <div id="error_icon_holder"></div> When they're added, the markup should resemble: <div id="error_icon_holder"> <div class="error_icon"></div> </div> I tried using .addClass, but that resulted in: <div id="error_ic...

How do you organize methods and properties within a class?

Say you're declaring a class with all the bells and whistles - constructor and destructor, public, private, protected and static methods and properties, magic methods, etc. How do you organize all this logically? For instance, do you group things by visibility? Do you alphabetize method names? Do you group magic methods together? Do you...

How do I populate a "ragged" array with values of a text file being read?

Hello, I'm new to Stack Overflow, and this is my first question/post! I'm working on a project for school using Java. The first part I'm having trouble with inolves: Read each line in a file (listed at the end of my post) one time Create a "ragged" array of integers, 4 by X, where my 4 rows will be the "region number" (the number found...

php upload file class

hi all, i am new to php i am in search of a php function in a class that accepts some parameters like size,type etc the class should be such that it should be able to set some default values to the parameters that are not assigned by user for ex the destination folder etc can anybody give me a link or some hint how should i do this ...

[python] can a python class contain an instance of itself as a data container

Dear All, Can a python class contain an instance of itself as a data container may look like this? class A: def __init__(self, val): self.a = A(val) self.val = val aa = A(2) #this will cause RuntimeError: maximum recursion depth exceeded my purpose is using this class as a data container contain a copy inside if...

php ReflectionClass

hey all i want to use ReflectionClass to load some classes defined in my xml file but i am getting an error Error while register class :Class ReportErrorHandler does not exist i will not get this error when i will use require_once( 'handlers/system/ReportErrorHandler.php' ); but i dont want to require_once the class ,this is w...

PHP Combining arrays with std class

Hello, This is what I want but cant figure out how to. $a is this array PHP Code: Array ( [0] => stdClass Object ( [id] => i1 [cat] => Test1 ) [1] => stdClass Object ( [id] => i2 [cat] => Test2 ) [2] => stdClass Object ( ...

conformance vs. inheritance in Cocoa/Objective-C classes

I noticed that Cocoa/Objective-C classes inherit and conform from other classes. I understand what inheritance is, but not conformance. What's the difference? Also, is a class like UIView a Cocoa class or an Objective-C class? ...

Difference between usage of Interfaces and implementation classes in Java

Possible Duplicate: Type List vs type ArrayList in Java Why is it recommended to do this: List<String> myArrayList = new ArrayList<String> or same with Map interface and HashMap class rather than: ArrayList<String> myArrayList = new ArrayList<String> ...

Functions outside the class

I just want to tell you that I am newbie to OOP and it is quite hard to me, but here is my code: class functions { function safe_query($string) { $string = mysql_escape_string(htmlspecialchars($string)); return $string; } } class info { public $text; function infos($value) { echo func...

Create a class type in code in .net c#

When I was looking to the System.Linq.Expression capabilities (creating expression trees in code, compiling them, executing them) I was asking myself if this is possible for class creation as well - specifically generic classes. I would expect something like Expression.Class() or Expression.GenericClass(). Looking at the methods I did n...

Adding a property without touching the class? (not inheritance)

I got a requirement in my project to add another property to some class. Now I want to avoid changing the class because I figured it shouldn't be aware that he has this property (this property only has significance in the context of this project). The way I thought to accomplish this was (Please critic this because I wanna know if there...

Destructing derived class by deleting base class

Hello, I have a situation that looks like the following code: #include <iostream> class A { public: A() { std::cout << "A created!" << std::endl; } ~A() { std::cout << "A destroyed!" << std::endl; } virtual const char* Name() { return "A"; } }; class B : public A { public: B() { std::cout << "B created!" << std::endl;...

Scope of class declaration

I have a file classes.php in which I declare a set of classes to be used in a series of pages. Then, in one page, I need to use another class, that is declared in a separate file. Now, this separate class uses some classes located in the classes.php file. So, in most pages, I have: [1] <?php require('classes.php'); [page code] ?> whi...

Declaring protected variables in methods

I've had a good look round and can't seem to find an answer to this problem. Basically I'm using the _call method to dynmically generate get and set methods, however when declaring a variable PHP's default is public. Is there anyway to declare a variable from within a class as protected? function __call($method, $arguments) { $pref...