class

How to pass a subclass parameter when implementing an interface in C#?

As a novice to OOP, I am trying to implement an interface method with a base parameter by passing a (needed) subclass parameter. I have: public interface IArticleDataAccess { int SaveArticle(NewsArticle thisArticle); } public AnalysisDataAccess : IArticleDataAccess { public int SaveArticle(AnalysisArticle thisArticle) { // Spec...

Why are some operators in C++ only allowed to be overloaded as member functions?

The operators are = () [] -> ->* conversion operators These can be declared only as member functions. Any other operator function can be either a class member or a non-member function. What is the rationale for this restriction? ...

XML to C# Class Question

Can someone please help me, I have this xml snippet <?xml version="1.0" encoding="utf-8" ?> <EmailConfiguration> <DataBoxID>123</DataBoxID> <DefaultSendToAddressCollection> <EmailAddress>[email protected]</EmailAddress> </DefaultSendToAddressCollection> </EmailConfiguration> I want to create a corressponding c# class from...

Scala equivalent of Java java.lang.Class<T> Object

The question is best explained by an example: In Java for a JPA EntityManager, I can do the following(Account is my Entity class): Account result = manager.find(Account.class, primaryKey); In Scala, my naive attempt is: val result = manager.find(Account.class, primaryKey) But when I try to use Account.class in Scala, it seems to n...

How to make a child class's methods static?

Hello, My parent class is a form(TParent) ,here's the code: type TChild = class(TParent) private procedure Handle(sock:integer);static; //error end; implementation The error is "STATIC can only be used on non-virtual methods" Is there any possible way of doing this? If not, can I make the Parent Class(TForm) static? The TParen...

Why my child class doesn't inherit all methods from the parent class?

Hello, If both classes are placed in one unit - there is no problem,the child class inherits private methods from the parent class,but if they are in different units,the class can access only public methods.Why? The child class can't access private methods only because they are in different units. How do I avoid this? In my case I hav...

Producing a list of all classes in a C++ project

I'm using Visual Studio 2008 (C++) and would like to produce a list of all classes that are defined in that project. Does anyone know tools that extract those easily? A simple 'Find in files' will not be sufficient, of course. Edit: The list of classes should be created automatically and the result should be a simple file of class name...

Get a variable from an external Class

I'm using an external class to draw an object in my Flash movie but I need to get some variables from the Class as well. I want to put the variable persPoints[0].x into a variable in my main document called newvar for example. This is the part of the External Class I'm using class Shape { function set2DTo3D():Void { var persPoi...

PHP Class won't return to a String

Hi, I'm fairly new to PHP so I have a small problem as I'm learning: I built a Class called DataStrip.php <?php final class DataStrip { public function DataStrip() { // constructor } public function stripVars($vars) { return $vars; } } ?> and then I'm trying to pass the public function stripVars a value: <?php inc...

Does Delphi's static keyword have any point in native-only code?

My understanding is that the static keyword was introduced for compatibility with .NET (along with strict) class TExample class procedure First; class procedure Second; static; The differences between procedures First and Second are :- First can be overridden in a descendant class First passes an implicit self parameter referenc...

Declare and initialise an array of struct/class at the same time

1. I know that it is possible to initialise an array of structures in the declaration. For example: struct BusStruct { string registration_number; string route; }; struct BusStruct BusDepot[] = { { "ED3280", "70" }, { "ED3536", "73" }, { "FP6583", "74A" }, }; If the structure is changed into a class, lik...

Rails not refreshing code

While developing a Rails app, I usually leave the dev server running locally (mongrel) as I work on the code. Changes in the code take affect after a quick refresh. EXCEPT changes havent been taking effect for a class I've been writing in the Lib in folder. Is this in any way a known problem? What could be causing this? It is very frustr...

When should we create a static class?

How can we distinguish to create a class which is static? ...

Business Layer, Data Access Layer. Is there any resource to learn how to make relation between Business layer classes with Data Access layer classes?

Business Layer, Data Access Layer. Is there any resource to learn how to make relation between Business layer classes with Data Access layer classes? ...

[PHP] accessing array from other function in a class

i have 2 functions in a class, in the first one i have something like that: public function func1() { $test = array(1,2,3); return $test; } how to copy the contents from $test in the second function? public function func2() { $newarray = $this->func1->test; print_r($newarray); } Sorry, but i have really no idea, how to make this :...

Anonymous Namespace Class Definition

I was looking over some (C++) code and found something like this: //Foo.cpp namespace { void SomeHelperFunctionA() {} void SomeHelperFunctionB() {} void SomeHelperFunctionC() {} //etc... class SomeClass //<--- { //Impl }; } SomeHelperFunction[A-Z] are functions that are only needed in that tra...

Does @Test(enabled = false) work for a class in TestNG?

From the TestNG doc I can see that (enabled = false) can be applied to a class or method. But it seems it only works when applied to a method. Anybody seen the same, found a solution? I'm running tests in ItelliJ IDEA 7.0 by the way. ...

PHP Class error on calling method

Hi, I have a class to connect to my database, strip stuff and return things from a db query. Anyhow, the problem I am having is that I am tryinmg to call runQuery() method but every time I try, I get this error: Fatal error: Call to undefined function runMyQuery() in DatabaseConnector.php line 22 Any ideas perhaps? I know runQuery ...

How to create Classes in Python with highly constrained instances

In Python, there are examples of built-in classes with highly constrained instances. For example, "None" is the only instance of its class, and in the bool class there are only two objects, "True" and "False" (I hope I am more-or-less correct so far). Another good example are integers: if a and b are instances of the int type the...

PHP Classes and including files

Hi all, I am needing some information on including files in PHP classes. E.G. include Foo2.php; //<--- Is this good? class Foo { function doFoo(){ include("Foo2.php"); //<--- or is this better? //do something with vars from Foo2 } } I was wondering what the differences were beside scope and if there...