class

Optional reference member - is it possible?

I have the following class class CItem { public: CItem(CRegistry &Registry) _Registry(Registry) {Registry.Register();} ~CItem() {_Registry.Unregister()}; private: CRegistry &_Registry; } After a while it turns out that not all CItem objects need to be registered so I need a version of CItem which does not requires Registry i...

JavaBeans Classes in Separate JAR Files

Is it possible to build classes for a JavaBean in separate JAR files? Specifically- a JavaBean has the Bean and BeanInfo classes in one JAR file and the Custom Property Editor class inn a different JAR, the JAR file with the Bean and BeanInfo classes has the JAR file with the Custom Property Editor class on the classpath, but during dra...

Java design issue - Adding functionality to fixed classes

I have a set of classes that all need to be acted on in some (individual) way. Ordinarily I'd just create a DoSomethingInterface with a single doSomething() method and have each class implement that method in a way that suits each class' needs. However, I cannot do that in this case as the class definitions are unmodifyable (auto-genera...

CSS ID vs Class

What is the basic difference between CSS ID and CSS Class? Someone told me that, ID can be used only once in a page. But I found that it can be used multiple times. like body { background-color: #3399FF; } div#menuPane{ position: absolute; left: 25px; top: 25px; width: 25%; } div.menu { display: block; ...

General MVC Questions - naming, structure (PHP)

Hello, I have tried many PHP MVC frameworks and I noticed that in many frameworks you can do things like this: $this->security->encodeForHTML(); So, basically there is a class Security, which contains a method encodeForHTML(). Isn't this Security class a singleton? Is there a specific name for this kind of "internal" singleton class?...

How to create a template function within a class? (C++)

I know it's possible to make a template function: template<typename T> void DoSomeThing(T x){} and it's possible to make a template class: template<typename T> class Object { public: int x; }; but is it possible to make a class not within a template, and then make a function in that class a template? Ie: //I have no idea if th...

Loading Java Classes which arent needed.

I'm currently wondering what the actual overhead, in the JVM, is for loading extra classes which are never used. We have code which iterates all the classes in the class path to find classes which implement a certain interface, we then load them. This allows custom classes to be simply dropped in a directory and they get loaded and reg...

Why cant we have static method in an inner class?

hi why cant we have static method in an inner class and if i make inner class static it works why so ...

How can I use the java for each loop with custom classes?

I think most coders have used code like the following : ArrayList<String> myStringList = getStringList(); for(String str : myStringList) { doSomethingWith(str); } How can I take advantage of the for each loop with my own classes? Is there an interface I should be implementing? ...

PHP and mysql connections

Is it possible to create a connection in a PHP class file and use it in all of the different methods in the class? I am trying to open a connection in the constructor and i get an error when i get to the close connection method saying that the argument that I've provided in the mysql_close() statement isn't a valid MYSQL-Link souce. ...

Splitting up a class into sub-classes

I've got a business logic layer class containing access methods for each table in a database. As there are quite a few tables now I'd like to restructure it to group the methods by entity (for easier access when coding). So, from this: BLL.Database MyDB = new BLL.Database(); BLL.Entity.User MyUser = Database.UserGetById(42); to this: ...

CSS Class name parameters?

Is there a more efficient way of declaring and using these (very similar/repetitive) CSS classes: div.rounded20 { -webkit-border-radius:20px; -moz-border-radius:20px; } div.rounded15 { -webkit-border-radius:15px; -moz-border-radius:15px; } Say maybe with something along the lines of: div.rounded(@Y) { -webkit-border-radius...

DRY'er Object Initialization in Ruby

Hi, Is there a more 'DRY' way to do the following in ruby? #!/usr/bin/env ruby class Volume attr_accessor :name, :size, :type, :owner, :date_created, :date_modified, :iscsi_target, :iscsi_portal SYSTEM = 0 DATA = 1 def initialize(args={:type => SYSTEM}) @name = args[:name] @size = args[:size] @type ...

Find out what class invoked a method

Is there any way, in C#, for a class or method to know who (i.e. what class/ method) invoked it? For example, I might have class a{ public void test(){ b temp = new b(); string output = temp.run(); } } class b{ public string run(){ **CODE HERE** } } Output: "Invoked by the 'test' method of class...

F# Assign Value to Class Member In Method

I'm playing around with F# in VS 2010 and i can't quite figure out how to assign a value to a member in a class. type SampleGame = class inherit Game override Game.Initialize() = spriteBatch <- new SpriteBatch(this.GraphicsDevice) base.Initialize() val mutable spriteBatch : SpriteBatch end I tho...

consecutive <li> classes

I have trouble finding an expression to automatically generate a new 'class' like the following: <ul> <li class="img1">link</li> <li class="img2">link</li> <li class="img3">link etc...</li> </ul> This is nested in 2 tabs for 'most read' / 'latest comments'. The different classes are so that I can make a different bullet (number) usin...

Class library modification / migration

I have 3 class libraries. A BBL, a DAL, and a DATA (about 15 datasets). Currently 4 [major] applications utilize the functionality in these DLL's. I'm rewriting one of those applications and I need to (1) Use some of the existing functionality in the libraries (2) Change some of it (3) Add new functionality (4) Add new datasets. I'm bac...

A question on an example in PHP 5 in Practice

HI, I don't understand why the author of a php book used $disks = 1 in a public function __construct($disks = 1)? I tried to replace $disks = 1 with $disks only, it also worked. Why would author doing that? <?php // Define our class for Compact disks class cd { // Declare variables (properties) public $artist; public $title...

F# Static Methods In Class

I'm trying to figure out how to make static methods in a class in F#. Does anyone have any idea how to do this? ...

Passing unnamed classes through functions

How do I pass this instance as a parameter into a function? class { public: void foo(); } bar; Do I have to name the class? It is copyable since I haven't made the class's copy ctor private. So how is it possible if at all? ...