class

C++ : Swapping template class elements of different types?

template< class T1, class T2 > class Pair { T1 first; T2 second; }; I'm being asked to write a swap() method so that the first element becomes the second and the second the first. I have: Pair<T2,T1> swap() { return Pair<T2,T1>(second, first); } But this returns a new object rather than swapping, where I think it needs t...

Passing enum parameter to a case class does not work

Can someone tell me why this does not work? case class XY(enum: MyEnum) object MyEnum extends Enumeration { val OP1, OP2 = Value } Error: not found: type MyEnum ...

C# call interface method within class

interface ILol { void LOL(); } class Rofl : ILol { void ILol.LOL() { GlobalLOLHandler.RaiseROFLCOPTER(this); } public Rofl() { //Is there shorter way of writing this or i is there "other" problem with implementation?? (this as ILol).LOL(); } } ...

Class Design Question

This is a super newbie question, I've been programming for a while, but am just learning OOP. I have a class that works with user input via the C# console. There are different methods in this class to gather different input sets. I have another class that takes these input sets and puts them in a database. What is the best way to pas...

super function doesn't work inside a maya python module

Somehow, this works fine in the Maya/Python script editor, but fails when it's inside of my module code. Anyone have any ideas? class ControlShape(object): def __init__(self, *args, **kwargs): print 'Inside ControlShape...' class Cross(ControlShape): def __init__(self, *args, **kwargs): print 'Entering Cross...'...

Java method: retrieve the inheriting type

I have several classes that extend C and I would need a method that accepts any argument of type C. But in this method I would like to know if I'm dealing with A or B. * public A extends C public B extends C public void goForIt(C c)() If I cast how can I retrieve the type in a clean way (I just read using getClass or instanceof is o...

Class; Struct; Enum confusion, what is better?

I have 46 rows of information, 2 columns each row ("Code Number", "Description"). These codes are returned to the client dependent upon the success or failure of their initial submission request. I do not want to use a database file (csv, sqlite, etc) for the storage/access. The closest type that I can think of for how I want these code...

Target MovieClip from non-Document Class in Flash

Hi, is there any way to target a MovieClip from an external class that's NOT the Document Class? Is it correct to have the Document Class as Main AND View? ...

Add child to scene from within a class.

Hi, I'm new to flash in general and have been writing a program with two classes that extend MovieClip (Stems and Star). I need to create a new Stems object as a child of the scene when the user stops dragging a Star object, but do not know how to reference the scene from within the Star class's code. I've tried passing the scene into...

C++ Beginner - Trouble using structs and constants!

Hello everyone! I am currently working on a simple Scrabble implementation for a college project. I can't get a part of it to work, though! Check this out: My board.h: http://pastebin.com/J9t8VvvB The subroutine where the error lies: //Following snippet contained in board.cpp //I believe the function is self-explanatory... //Pos i...

Field Members vs Method Variables?

Recently I've been thinking about performance difference between class field members and method variables. What exactly I mean is in the example below : Lets say we have a DataContext object for Linq2SQL class DataLayer { ProductDataContext context = new ProductDataContext(); public IQueryable<Product> GetData() { r...

Beginner C++ - Trouble using global constants in a header file

Hello! Yet another Scrabble project question... This is a simple one. It seems I am having trouble getting my global constants recognized: My board.h: http://pastebin.com/7a5Uyvb8 Errors returned: 1>C:\Users\Francisco\Documents\FEUP\1A2S\PROG\projecto3\projecto3\Board.h(34): error: variable "TOTAL_ROWS" is not a type name 1> ...

Can I make a derived class inherit a derived member from its base class in Java?

I have code that looks like this: public class A { public void doStuff() { System.out.print("Stuff successfully done"); } } public class B extends A { public void doStuff() { System.out.print("Stuff successfully done, but in a different way"); } public void doMoreStuff() { Syste...

Can an element have both an id and a class?

pretty self-explanatory. ...

How to use a separate class to validate credit card numbers in C#

I have set up a class to validate credit card numbers. The credit card type and number are selected on a form in a separate class. I'm trying to figure out how to get the credit card type and number that are selected in the other class (frmPayment) in to my credit card class algorithm: public enum CardType { MasterCard, Visa, Amer...

wxPython dictionary of classes to events they call

I was wondering if there was a dictionary containing string versions of wxPython class (like 'Button' for wx.Button) to the events they call. This is what I want: {'Button': wx.EVT_BUTTON, ...}. Is there a dictionary like this anywhere in the module or on the web? ...

Java: Typecasting to Generics

This method that uses method-level generics, that parses the values from a custom POJO, JXlistOfKeyValuePairs (which is exactly that). The only thing is that both the keys and values in JXlistOfKeyValuePairs are Strings. This method wants to taken in, in addition to the JXlistOfKeyValuePairs instance, a Class<T> that defines which data ...

Classes with the same name - is it restricted only within the same translation unit?

Let's just I had the following code: foo.h class Foo { // ... }; foo.cpp #include "foo.h" // Functions for class Foo defined here... Let's say that Foo are built into a static library foo.lib. Now let's say I have the following: foo2.h class Foo { // ... }; foo2.cpp #include "foo2.h" // Functions for class Foo define...

Can't create a Collection of Inherited Classes

Maybe I just don't know what to search for, but I'm going a little bonkers here trying to figure out how to create a collection of inherited classes. The base class, I will never use. Basically, I have 3 components: A base class call ImageFormat Child classes of ImageForm Code in Sub Main() to loop create a collection and loop through...

Improve this snippet from a prototype class

This is a snippet from a prototype class i am putting together. The scoping workaround feels a little hacky to me, can it be improved or done differently? var myClass = Class.create({ initialize: function() { $('formid').getElements().each(function(el){ $(el).observe("blur", function(){ this.valid...