class

c++ (non-built in/class) static member

#include <iostream> #include <string> class c1 { public: static std::string m1; static unsigned int m2; }; //std::string c1::m1 = std::string; unsigned int c1::m2 = 0; void main() { c1 a; //std::cout<<a.m1<<std::endl; std::cout<<a.m2<<std::endl; } In this program enabling the two remarked lines causes an error on the first. ...

Restrict what can create a PHP Class

I got two classes, "A" and "B". In the application logic no one is allowed to create an object of class "B", except for class "A". But, since I dont want to have the two classes in the same file I cant restrict it with the "private" properity. Is it possible to create this kind of restriction? If someone other then "A" tries to create...

jQuery scroll is not working correctly when inside div

I created a jQuery function that applies a class to a paragraph, and then scrolls to that paragraph when a button is clicked. It works fine when the paragraphs are relative to the document, but I want the scroll to happen inside a div. Currently, the scrolling is working, and it is applying the class correctly, but it is does not scroll ...

php design question

Hello all, I have the following class: class Apiconnect { const URL = 'https://someurl.com/api.php'; const USERNAME = 'user'; const PASSWORD = 'pass'; /** * * @param <array> $postFields * @return SimpleXMLElement * @desc this connects but also sends and retrieves the information returned in XML */ public function Apiconnect($...

Database factory class design

Hi i have this class to instantiate DAL classes: public class Factory { public static T GetInstance<T>() where T : new() { return new T(); } } I want to make my application capable of using multiple databases. I was planning on setting the database in my web.config and then pass in that setting possibly to the fac...

get all class constants

Is there a way to do get all the constants in a php class. Tried get_class_vars( get_called_class() ) class Status { const PUBLISHED = "published"; const DRAFT = "draft"; public static function get_types() { return array(self::PUBLISHED, self::DRAFT); } } Thanks ...

Using C++0x TR1 random in a class, for low overhead

Hello, I'm using VC 2010 and trying to keep the overhead and duplicated code of certain functions low, by placing the random definitions in the constructor of each class instance, then calling as necessary from there. What I have now, simplified, is: #include <random> #include <Windows.h> mt19937 eng(GetTickCount()); class Cycles { ...

As3 - Assign class to object on stage

Hello, I think the title should make it pretty clear. I was wondering how you can assign a class to an object on stage. As you would do with actionscript: var objectname:ClassName = new ClassName(); This would make a new object, but the current object already exists, it just needs to be notified that it's of the type "ClassName" so it...

Dynamically assign to class

Here is what works: $some = new Something(); $some->user="username"; $some->password="password123"; i need: $some = new Something(); $some->user=$variable1; $some->user=$variable2; Please please, can i get quickest way to make it work ? Thanks! ...

Javascript Prototyping Error

I've been looking into Javascript prototyping recently, can understand the theory, and believe it can be very useful to my understanding of the language, but can't quite get the following to work... var player = function(){//Declarations here}; var super_player.prototype = new player(); Every compiler/checker flags a 'missing semicolo...

C++: How to pass results from one class to another class?

I have one class to read data (data.h & data.cpp), one class to analysis data (analysis.h & analysis.cpp) and another one to do calculation based on two previous classes (calculation.h & calculation.cpp). I wonder how can I pass the results from data class to analysis class and later on from both of them to calculation class. I tried to ...

If a class is blueprint for objects, what about static class?

Reading C# Step by Step, the author mentiones the class is just blueprint for objects and itself is useless. Well, how then comes static classes can work alone? I do understand the concept that static classes cannot be instantiated and exist as one unique instance with its static members. But that ruins, a bit, the metaphor of classes...

unexplained syntax error defining threadpool inside class definition

I have the following class definition and for some reason I cannot define the threadpool inside the class definition itself. It says: syntax error: identifier 'numberofpoolthreads' I tried directly defining it in the class, but it gives me same syntax error, does anyone know why this is? #include "stdafx.h" #include <boost/threadpool....

'System.Configuration.ConfigurationSettings.AppSettings' is obsolete

I got the following warning 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: '"This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings"' How do you fix it? ...

Two Classes Dependent On Each Other

I have Camera class, which handles camera behavior. Among it's fields is a reference to the target's Cube class (Cube is just one of the object, but I won't mention others to keep it simple). In order to calculate the View matrix, I need the camera's position and target's position, so I can explain to my program that: "the camera is plac...

How to add an HTML class to a PHP script

Hi, First off, I don't know much (quite nothing) about PHP. I'm more familiar with CSS. I'm making use of Ben Ward script Tumblr2Wordpress (here's the script on GitHub) to export my Tumblr blog in XML (so I can import it in my Wordpress blog). This script reads tumblr's API, queries elements, do a bit of formatting and export the whole...

Objective-c: Dynamic Class Names

I'm not sure if I worded the subject correctly. I am looping through an array, within each loop I am trying to instantiate a class, but I want to dynamically create the name. Like so: int i = 0; for(NSString* thisdatarow in filedata) { i++; NSString* thisad = [NSString stringWithFormat:@"ad%d", i]; NSLog(@"%@", thisad); ...

What does <> mean when defining an interface

I learning about writing my own interfaces and came across this msdn article. Everything seems fine, except I cannot find anywhere what the < T > means or does. Can anyone help me out? interface IEquatable<T> { bool Equals(T obj); } ...

Learning C# Issues with Array (Array Data Vanishes)

This is likely a scoping issue but the following code dies. I build a multi-dimensional array from 2 classes, Cell and Map. The map is an X by Y sized grid of Cells. Pretty normal so far (I keep re-writing this same program when I learn a new language). For brevity I'll just post the classes and a basic test that reflects the error. When...

Class inheritance for GUI using wxpython

I have a very simple GUI that accepts two parameters and then calls three other classes whose names are DigitalFilter(), BeatByBeatVariables(), and GetSummaryOfWholeTest(). This is my first time writing up classes, and I need help with the syntax. Specifically, can you help me with inheritance? I want the GUI's class MainWindow(wx.Fra...