Search Results

Search found 9771 results on 391 pages for 'equivalence classes'.

Page 46/391 | < Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >

  • Common type for generic classes of different types

    - by DinGODzilla
    I have (for example) Dictionary of different generic types (d1, d2, d3, d4) and I want to store them in something var d1 = new Dictionary<int, string>(); var d2 = new Dictionary<int, long>(); var d3 = new Dictionary<DateTime, bool>(); var d4 = new Dictionary<string, object>(); var something = ??? //new List<object> {d1, d2, d3, d4}; Is there any other way how to store that in something with common denominator different than object? Thanks :-)

    Read the article

  • Getting Reference to Calling Activity from AsyncTask (NOT as an inner class)

    - by stormin986
    Is it at all possible, from within an AsyncTask that is NOT an inner class of the calling Activity class, to get a reference to the instance of Activity that initiated execution of the AsyncTask? I am aware of this thread, however it doesn't exactly address how to reference the calling Activity. Some suggest passing a reference to the Activity as a parameter to the AsyncTask constructor, however, it's reported that doing so will always result in a NullPointerException. So, I'm at a loss. My AsyncTask provides robust functionality, and I don't want to have to duplicate it as an inner class in every Activity that wants to use it. There must be an elegant solution.

    Read the article

  • How to get java singleton object manager to return any type of object?

    - by Robert
    I'm writing an interactive fiction game in java from scratch. I'm currently storing all of my game object references in a hashmap in a singleton called ObjectManager. ObjectManager has a function called get which takes an integer ID and returns the appropriate reference. The problem is that it returns a BaseObject when I need to return subclasses of BaseObject with more functionality. So, what I've done so far is I've added a getEntity function which returns BaseEntity (which is a subclass of BaseObject). However, when I need the function to return to an object that is a subclass of BaseEntity that has added, required functionality, I will need to make another function. I know there is a better way, but I don't know what it is. I know very little of design patterns, and I'm not sure which one to use here. I tried passing 'class' as a parameter, but that didn't get me anywhere. public BaseObject get(int ID){ return (BaseObject)refMap.get(ID); } public BaseEntity getEntity(int ID){ return (BaseEntity)refMap.get(ID); } Thanks, java ninjas!

    Read the article

  • Access specifier's and classes and objects?

    - by TimothyTech
    Alright, im trying to understand this, so a class is simply creating a template for an object. class Bow { int arrows; }; and an object is simply creating a specific item using the class template. Bow::Bow(arrows) { arrows = 20; } also another question, public specifiers are used to make data members avaible in objects and private specifiers are used to make data memebers only avaialble inside the class?

    Read the article

  • How to implement callback functions inside classes (PHP)

    - by sombe
    I need to use a class callback method on an array inside another method (the callback function belongs to the class). class Database { public function escape_string_for_db($string){ return mysql_real_escape_string($string); } public function escape_all_array($array){ return array_filter($array,"$this->escape_string_for_db"); } } Is this the right way to go about that? (I mean, in terms of the second parameter passed to array_filter)

    Read the article

  • Creating C# Classes at runtime

    - by John Hartsock
    Hello, I have been curious about dynamically create class at runtime in C# and stumbled across this article. http://olondono.blogspot.com/2008/02/creating-code-at-runtime.html I am curious to hear some pros and cons regarding construction of a class at runtime. Any opinions?

    Read the article

  • C++: What is the size of an object of an empty class?

    - by Ashwin
    I was wondering what could be the size of an object of an empty class. It surely could not be 0 bytes since it should be possible to reference and point to it like any other object. But, how big is such an object? I used this small program: #include <iostream> using namespace std; class Empty {}; int main() { Empty e; cerr << sizeof(e) << endl; return 0; } The output I got on both Visual C++ and Cygwin-g++ compilers was 1 byte! This was a little surprising to me since I was expecting it to be of the size of the machine word (32 bits or 4 bytes). Can anyone explain why the size of 1 byte? Why not 4 bytes? Is this dependent on compiler or the machine too? Also, can someone give a more cogent reason for why an empty class object will not be of size 0 bytes?

    Read the article

  • Accessing initialized variable on different class C++

    - by d0pe
    I'm having some difficulties with this problem. The main idea is, I initialized a variable of class type B in class A, class A.h has the variable Z declared as public, like B *Z; In class A.cpp, I initialized it as Z = new B(); Now, I want to access that variable from class C and I'm unable to do so. C.h includes A.h and B.h

    Read the article

  • jQuery Animation and Classes

    - by ehdv
    Assume you have a list item, <li id="foo"> which you want to fade from one color to another when moused over, and that you are using jQuery. This is fairly easy: $('li#foo').bind('mouseenter' , function(e) { $(this).animate({backgroundColor: '#F00'} , 300); }); However, what if you wanted to get the resulting color or other style rules from a class defined in CSS without also declaring them in JavaScript? It seems there's no way to learn style information from CSS rules without having an example of the rule already in the document, which would require you to animate the <li> to the target appearance, then in the animation-finished callback, set the class which leads to redundant style declarations and can foul up your CSS at "runtime". Sorry if this question's unclear: It doesn't occur in the context of any specific project, I'm just curious how you'd go about this. Also, I know CSS3 hypothetically includes support for such transitions but using CSS for dynamic behavior like this seems such an ugly hack.

    Read the article

  • question regarding "this" pointer in c++

    - by sil3nt
    hello there, i have been given class with int variables x and y in private, and an operator overload function, class Bag{ private: int x; int y; public: Bag(); ~Bag(); //....... //.....etc }; Bag operator+ (Bag new) const{ Bag result(*this); //what does this mean? result.x += new.x; result.y += new.y; } What is the effect of having "Bag result(*this);" there?.

    Read the article

  • Same function on multiple div classes doesn't work

    - by Sebass van Boxel
    I'm doing something terribly wrong and just can't find the solution for it. Situation: I've got a number of products with a number of quotes per product. Those quote automatically scroll in a div. If the scroll reaches the last quote is scroll back to the first one. What works: The function basically works when it's applied on 1 div, but when applied on multiple div it doesn't scroll back to the first one or keeps scrolling endlessly. This is the function i've written for this: function quoteSlide(divname){ $total = ($(divname+" > div").size()) $width = $total * 160; $(divname).css('width', ($width)); console.log ($totalleft *-1); if ($width - 160 > $totalleft *-1){ $currentleft = $(divname).css('left'); $step = -160; $totalleft = parseInt($currentleft)+$step; }else{ $totalleft = 0; } $(divname).animate(     { left: $totalleft }, // what we are animating     'slow', // how fast we are animating     'swing', // the type of easing     function() { // the callback }); } It's being executed by something like: quoteSlide('#quotecontainer_1'); in combination with a setInterval so it keeps scrolling automatically. This is the jsFiddle where it goes wrong (So applied on more than 1 div) http://jsfiddle.net/FsrbZ/. This is the jsFiddle where everything goes okay. (applied on 1 div) When changing the following: quoteSlide('#quotecontainer_1'); quoteSlide('#quotecontainer_2'); setInterval(function() { quoteSlide('#quotecontainer_1'); quoteSlide('#quotecontainer_2'); }, 3400);? to quoteSlide('#quotecontainer_1'); setInterval(function() { quoteSlide('#quotecontainer_1'); }, 3400);? it does work... but only on 1 quotecontainer.

    Read the article

  • C++: Initialization Order for Member Classes

    - by Nikhil
    In the following code, when the ctor of X is called will the ctor of A or B be called first? Does the order in which they are placed in the body of the class control this? If somebody can provide a snippet of text from the C++ standard that talks about this issue, that would be perfect. class A; class B; class X { private: A a; B b; }

    Read the article

  • C++ Template Classes and Copy Construction

    - by themoondothshine
    Is there any way I can construct an new object from the given object if the template parameters of both objects are identical at run-time? For example: I have a template class with the declaration: template<typename _Type1, typename _Type2> class Object; Next, I have two instantiations of the template: template class Object<char, int>; template class Object<wchar_t, wint_t>; Now, I want to write a member function such as: template<typename _Type1, typename _Type2> Object<char, int> Object<_Type1, _Type2>::toCharObject() { if(__gnu_cxx::__are_same<_Type1, char>::__value) return *this; else { //Perform some kind of conversion and return an Object<char, int> } } I have tried a couple of techniques, such as using __gnu_cxx::__enable_if<__gnu_cxx::__are_same<_Type1, char>::__value, _Type1>::__type in a copy constructor for the Oject class, but I keep running into the error: error: conversion from ‘Object<wchar_t, wint_t>’ to non-scalar type ‘Object<char, int>’ requested Is there no way I can do this? Any help will be greatly appreciated!

    Read the article

  • Criteria: search for two different entity classes...

    - by RoCMe
    Hi! I have a "super entity" SuperEntity and three entities ChildEntity1, ..., ChildEntity3 which extends the super class. It's easy to search for all entities in the database, i.e. we could use session.createCriteria(SuperEntity.class); It's no problem to search for one specific entity type, too, just replace the SuperEntity with any of the children to look for entities of that type. But I have a problem when allowing 'multiple choice' for the types. I.e., it could be neccessary to search all entities of type 1 and 2, but not of type 3. A first idea was to create two independent queries and join the results in a final list - but that would destroy the paging which uses offset and limit functionality of the database... Is there a possibility in Criteria to join two different queries in one single result list? Kind regards, RoCMe

    Read the article

  • C++ methods which take templated classes as argument.

    - by Nils
    I have a templated class Vector<class T, int N> Where T is the type of the components (double for example) and n the number of components (so N=3 for a 3D vector) Now I want to write a method like double findStepsize(Vector<double,2> v) {..} I want to do this also for three and higher dimensional vectors. Of course I could just introduce further methods for higher dimensions, but the methods would have a lot of redundant code, so I want a more generic solution. Is there a way to create a method which takes a templated class without further specializing it (in this case without specifying T or N)? Like double findStepsize(Vector<T,N> v) ?

    Read the article

  • Pointer-like behavior in Java

    - by Shmoo
    I got the following: class A{ int foo; } class B extends A{ public void bar(); } I got a instance of A and want to convert it to an instance of B without losing the reference to the variable foo. For example: A a = new A(); a.foo = 2; B b = a; <-- what I want to do. //use b b.foo = 3; //a.foo should now be 3 Thanks for any help!

    Read the article

  • Car Class (first time with classes)

    - by user2967605
    For an assignment I needed to use a class named car and have it display the make and model, and also have the speed increase by 5 when you use accelerate and decrease by 5 when you brake. My teacher helped me along the way but when I got to the end I couldn't get it to run. Could someone correct me and tell my why it's wrong? Imp--------- #include <iostream> #include <string> using namespace std; void accelerate() { int speed; speed = speed + 5; } void brake() { int speed; speed = speed - 5; } Header #include <iostream> #include <string> using namespace std; class car { public: car(int getYear, string getMake); void accelerate(); void brake(); private: int year; string make; int speed; }; CarClass.cpp #include <string> #include "CarClass.h" using namespace std; int main() { car.(2013,"Kia") car.accelerate() car.brake() }

    Read the article

  • C++ array of classes

    - by nickik
    I working on a game but I have a problem with the initialization of the level. (feld is just field in german) class level{ private: feld spielfeld[10][10]; public: /* other staff */ void init_feld(); }; void level::init_feld() { for(int i=0;i!=10;i++){ for(int n=0;n!=10;n++){ spielfeld[i][n] = new feld(land, i, n); } } } The Error: Error: no match for »operator=« in »((level*)this)-level::spielfeld[i][n] = (operator new(24u), (, ((feld*))))« /home/nick/stratego/feld.h:18:11: Remark: candidate is: feld& feld::operator=(const feld&) Process terminated with status 1 (0 minutes, 0 seconds) 2 errors, 0 warnings

    Read the article

  • C# do nested classes need to be instantiated?

    - by JL
    In the following scenario: public class outerclass { public innerClass Ic {get;set} public class innerClass { } } Do you need to instantiate the inner class property before assigning values to it, like this? public class outerclass { public outerclass() { this.Ic = new innerClass(); } public innerClass Ic {get;set} public class innerClass { } }

    Read the article

  • Problem with C++ classes

    - by Mike
    I have a class defined called extBlock. I then make an instance of that class with this extBlock mainBlock = new extBlock(1, 1024); I get this error: error C2440: 'initializing' : cannot convert from 'extBlock *' to 'extBlock' Can anyone help me with why I am getting this error. I have seen examples online of declaring it like this with a pointer extBlock *mainBlock = new extBlock(1, 1024); But if I do it this way it does not let me call the functions of mainBlock

    Read the article

  • Accessing variables in other classes (Java)

    - by George
    Why doesn't the following program return 0, since I am accessing p from a new A(), which has not had main called on it? public class A { public int p = 0; public static void main(String[] args) { p = Integer.parseInt(args[0]); new B().go(); } } class B { public void go() { System.out.println(new A().p); } }

    Read the article

< Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >