Search Results

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

Page 34/391 | < Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >

  • Address calling class [Java]

    - by Samuel
    Hello! [I am rather new to Java and Object Oriented programming] I have an abstract class Moveable with the method abstract void move() which is extended by the class Bullet and the abstract class Character, and Character is extended by the class Survivor and the class Zombie. In Survivor and Bullet the move() method doesnt require any parameters while in the class Zombie the move() method depends on the actual position of the survivor. The survivor and multiple zombies are created in the class Gui. I wanted to access the survivor in Zombie - what's the best way of doing this? In Gui i wrote a method getSurvivor() but i don't see how to access this method in Zombie? I am aware that as a workaround i could just pass a [Survivor survivor] as parameter in move() and ignore it in Bullet and Survivor, but that feels so ... bad practice. Thank you for your time! Samuel [I am not sure what tags to set here, please correct me if i'm wrong]

    Read the article

  • Creating C++ objects

    - by Phenom
    I noticed that there are two ways to create C++ objects: BTree *btree = new BTree; and BTree btree; From what I can tell, the only difference is in how class objects are accessed (. vs. - operator), and when the first way is used, private integers get initialized to 0. Which way is better, and what's the difference? How do you know when to use one or the other?

    Read the article

  • inner class within Interface

    - by harigm
    is that possible to create a inner class within an interface? If yes, why do we create like that? Anyways we are not going to create any interface objects? Do they help in any Development process?

    Read the article

  • Memory leak of java.lang.ref.WeakReference objects inside JDK classes

    - by mandye
    The following simple code reproduces the growth of java.lang.ref.WeakReference objects in the heap: public static void main(String[] args) throws Exception { while (true) { java.util.logging.Logger.getAnonymousLogger(); Thread.sleep(1); } } Here is the output of jmap command within a few seconds interval: user@t1007:~ jmap -d64 -histo:live 29201|grep WeakReference 8: 22493 1079664 java.lang.ref.WeakReference 31: 1 32144 [Ljava.lang.ref.WeakReference; 106: 17 952 com.sun.jmx.mbeanserver.WeakIdentityHashMap$IdentityWeakReference user@t1007:~ jmap -d64 -histo:live 29201|grep WeakReference 8: 23191 1113168 java.lang.ref.WeakReference 31: 1 32144 [Ljava.lang.ref.WeakReference; 103: 17 952 com.sun.jmx.mbeanserver.WeakIdentityHashMap$IdentityWeakReference user@t1007:~ jmap -d64 -histo:live 29201|grep WeakReference 8: 23804 1142592 java.lang.ref.WeakReference 31: 1 32144 [Ljava.lang.ref.WeakReference; 103: 17 952 com.sun.jmx.mbeanserver.WeakIdentityHashMap$IdentityWeakReference Note that jmap command forces FullGC. JVM settings: export JVM_OPT="\ -d64 \ -Xms200m -Xmx200m \ -XX:MaxNewSize=64m \ -XX:NewSize=64m \ -XX:+UseParNewGC \ -XX:+UseConcMarkSweepGC \ -XX:MaxTenuringThreshold=10 \ -XX:SurvivorRatio=2 \ -XX:CMSInitiatingOccupancyFraction=60 \ -XX:+UseCMSInitiatingOccupancyOnly \ -XX:+CMSParallelRemarkEnabled \ -XX:+DisableExplicitGC \ -XX:+CMSClassUnloadingEnabled \ -XX:+PrintGCTimeStamps \ -XX:+PrintGCDetails \ -XX:+PrintTenuringDistribution \ -XX:+PrintGCApplicationConcurrentTime \ -XX:+PrintGCApplicationStoppedTime \ -XX:+PrintGCApplicationStoppedTime \ -XX:+PrintClassHistogram \ -XX:+ParallelRefProcEnabled \ -XX:SoftRefLRUPolicyMSPerMB=1 \ -verbose:gc \ -Xloggc:$GCLOGFILE" java version "1.6.0_18" Java(TM) SE Runtime Environment (build 1.6.0_18-b07) Java HotSpot(TM) Server VM (build 16.0-b13, mixed mode) Solaris 10/Sun Fire(TM) T1000

    Read the article

  • Clear all class variables between instances

    - by ensnare
    This is probably a stupid question, but what's the best way to clear class variables between instances? I know I could reset each variable individually in the constructor; but is there a way to do this in bulk? Or am I doing something totally wrong that requires a different approach? Thanks for helping ... class User(): def __init__(self): #RESET ALL CLASS VARIABLES def commit(self): #Commit variables to database >>u = User() >>u.name = 'Jason' >>u.email = '[email protected]' >>u.commit() So that each time User is called the variables are fresh. Thanks.

    Read the article

  • VB.NET - Send [Delegate] through the classes to set AddressOf

    - by sv88erik
    How can I put AddressOf, from another class? I get this error 'AddressOf' operand must be the name of a method (without parentheses). " Is there an Eval () function in VB.NET? Or how does one do this? Public Shared Property e As UserControl Public Shared Sub SetButton(ByVal button As String, ByVal Objekt As [Delegate]) Dim errorbuttom1 As Button = e.FindName("errorButton1") AddHandler errorbuttom1.Click, AddressOf Objekt End Sub

    Read the article

  • classes and static variables in shared libraries

    - by abel
    I am trying to write something in c++ with an architecture like: App -- Core (.so) <-- Plugins (.so's) for linux, mac and windows. The Core is implicitly linked to App and Plugins are explicitly linked with dlopen/LoadLibrary to App. The problem I have: static variables in Core are duplicated at run-time -- Plugins and App have different copys of them. at least on mac, when a Plugin returns a pointer to App, dynamic casting that pointer in App always result in NULL. Can anyone give me some explanations and instructions for different platforms please? I know this may seem lazy to ask them all here but I really cannot find a systematic answer to this question.

    Read the article

  • LinqDataSource wizard table list is not refreshing after updating LinqToSql classes

    - by dotnet_learner
    I have changed my dbml file like this. I have deleted all the tables and stored procs. I added new tables and stored procs from a new database. In the code-behind, I can access the new tables and stored procs. However, in the LinqDataSource using the same dbContext when I'm trying to configure the LinqDataSource. I can see all the old tables in the wizard drop-down. How to refresh the the wizard drop-down so that I can select the newly added tables? Deleting the old LinqDataSourceand adding a new one is not working.

    Read the article

  • How to access "overridden" inner class in Scala?

    - by doom2.wad
    I have two traits, one extending the other, each with an inner class, one extending the other, with the same names: trait A { class X { def x() = doSomething() } } trait B extends A { class X extends super.X { override def x() = doSomethingElse() } } class C extends B { val x = new X() // here B.X is instantiated val y = new A.X() // does not compile val z = new A.this.X() // does not compile } How do I access A.X class in the C class's body? Renaming B.X not to hide A.X is not a preferred way. To make things a bit complicated, in the situation I have encountered this problem the traits have type parameters (not shown in this example).

    Read the article

  • Eclipse says I don't implement Enumeration, but I do

    - by Harm De Weirdt
    Goodmorning everybody, I'm having a little problem with a project for school. We are told to make an Iterator that implements Enumeration over a Hashmap. So i made this Enumeration: public Enumeration<Object> getEnumeration() { return new Enumeration<Object>() { private int itemsDone = 0; Collection<Long> keysCollection = getContent().keySet(); Long [] keys = keysCollection.toArray(new Long[keysCollection.size()]); @Override public boolean hasMoreElements() { if(itemsDone < getContent().size() +1 ) { return true; }else { return false; } } @Override public Object nextElement() { return getContent().get(keys[itemsDone++]); } }; } This goes in my Backpack class public class Backpack extends Item implements Carrier, Enumeration<Object>{ The hashmap is returned by getContent(). The problem now is that eclipse keeps telling me I havent implemented the methods from Enumeration. If I use the quick fix it just adds the hasMoreElements() and nextElement() dummy methods in my class. Somehow it doesn't see these methods in the inner class.. Can anyone help me please? Any help is appreciated.

    Read the article

  • .net generate proxy classes problem (wsdl/svchost) by soapHeader

    - by Oguzhan
    I'm using a web service from .Net C# client application. My web service has a method which return generic list and in my client application I use Configuration Service Reference to change array to generic list.Its working correctly. But when I add a soapHeader to my web service Configuration Service Reference to change array to generic list its not working and return Array instead of generic list. public class Service1 : System.Web.Services.WebService { public Authentication authentication = new Authentication(); [SoapHeader("authentication")] [WebMethod] public List<string> HelloWorld() { List<string> result = new List<string>(); result.Add("oguzhan"); return result; } } public class Authentication : SoapHeader { public string username; public string password; }

    Read the article

  • Eclipse (Springsource Tool Suite 2.3.1) can't resolve dependencies for classes in the same package

    - by Steve
    This started happening when I upgraded my Springsource Toolsuite from 2.3 to 2.3.1. Essentially whenever I do anything, such as open a file, change a file, etc, I have to do a clean. Everything works fine when I do mvn commands on the command line, which leads me to believe that Eclipse is looking in the wrong place for compiled code or something along those lines, although that is entirely superstitious at this point. Example: I make a change to com.foo.mypackage.MyClass. Suddenly a bunch of tests that excercise MyClass get the red x - for class not found! In src/main/test: com.foo.DbUnitTest com.foo.mypackage.FooTest extends DbUnitTest DbUnitTest gets a class not found. I do a clean, and everything is fine. I touch something, and it breaks again :(. I don't really know where to begin on how to troubleshoot this.

    Read the article

  • [Haskell] Problem when mixing type classes and type families

    - by Giuseppe Maggiore
    Hi! This code compiles fine: {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, FlexibleContexts, EmptyDataDecls, ScopedTypeVariables, TypeOperators, TypeSynonymInstances, TypeFamilies #-} class Sel a s b where type Res a s b :: * instance Sel a s b where type Res a s b = (s -> (b,s)) instance Sel a s (b->(c,a)) where type Res a s (b->(c,a)) = (b -> s -> (c,s)) but as soon as I add the R predicate ghc fails: {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, FlexibleContexts, EmptyDataDecls, ScopedTypeVariables, TypeOperators, TypeSynonymInstances, TypeFamilies #-} class Sel a s b where type Res a s b :: * instance Sel a s b where type Res a s b = (s -> (b,s)) class R a where type Rec a :: * cons :: a -> Rec a elim :: Rec a -> a instance Sel a s (b->(c,Rec a)) where type Res a s (b->(c,Rec a)) = (b -> s -> (c,s)) complaining that: Illegal type synonym family application in instance: b -> (c, Rec a) In the instance declaration for `Sel a s (b -> (c, Rec a))' what does it mean and (most importantly) how do I fix it? Thanks

    Read the article

  • A quick design question about C++ container classes in shared memory

    - by recipriversexclusion
    I am writing a simple wrapper around boost::interprocess's vector container to implement a ring buffer in shared memory (shm) for IPC. Assume that buf is an instance of RingBuffer created in shm. Now, in its ctor, buf itself allocates a private boost::interprocess::vector data member to store values, e.g. m_data. My question is: I think m_data should also be created in shared memory. But it this a necessity? What happens if buf that was created in shm itself, allocates standard memory, i.e. using new. Does this get allocated on the calling process's heap? I don't think buf is allocated there so how come a data member that is private to an object not on a process's heap gets allocated there. I'm confused.

    Read the article

  • How do I enumerate a list of interfaces that are directly defined on an inheriting class/interface?

    - by Jordan
    Given the following C# class: public class Foo : IEnumerable<int> { // implementation of Foo and all its inherited interfaces } I want a method like the following that doesn't fail on the assertions: public void SomeMethod() { // This doesn't work Type[] interfaces = typeof(Foo).GetInterfaces(); Debug.Assert(interfaces != null); Debug.Assert(interfaces.Length == 1); Debug.Assert(interfaces[0] == typeof(IEnumerable<int>)); } Can someone help by fixing this method so the assertions don't fail? Calling typeof(Foo).GetInterfaces() doesn't work because it returns the entire interface hierarchy (i.e. interfaces variable contains IEnumerable<int> and IEnumerable), not just the top level.

    Read the article

  • Overriding classes/functions from a .dll.

    - by Jeff
    Say I have class A and class B. B inherits from class A, and implements a few virtual functions. The only problem is that B is defined in a .dll. Right now, I have a function that returns an instance of class A, but it retrieves that from a static function in the .dll that returns an instance of class B. My plan is to call the created object, and hopefully, have the functions in the .dll executed instead of the functions defined in class A. For some reason, I keep getting restricted memory access errors. Is there something I don't understand that will keep this plan from working?

    Read the article

  • How to rebuild C# Class from XML

    - by mcass20
    I would like to save an instance of a c#.NET class in SQL for later retrieval. I am able to use LINQ to SQL to add a record complete with all the xml that makes up the class. Now how do I retrieve that xml and reconstruct the class object instance?

    Read the article

  • Why cant partial methods be public if the implementation is in the same assembly?

    - by Simon
    According to this http://msdn.microsoft.com/en-us/library/wa80x488.aspx "Partial methods are implicitly private" So you can have this // Definition in file1.cs partial void Method1(); // Implementation in file2.cs partial void Method1() { // method body } But you cant have this // Definition in file1.cs public partial void Method1(); // Implementation in file2.cs public partial void Method1() { // method body } But why is this? Is there some reason the compiler cant handle public partial methods?

    Read the article

  • Calling function using 'new' is less expensive than without it?

    - by Matthew Taylor
    Given this very familiar model of prototypal construction: function Rectangle(w,h) { this.width = w; this.height = h; } Rectangle.prototype.area = function() { return this.width * this.height; }; Can anyone explain why calling "new Rectangle(2,3)" is consistently 10x FASTER than calling "Rectangle(2,3)" without the 'new' keyword? I would have assumed that because new adds more complexity to the execution of a function by getting prototypes involved, it would be slower. Example: var myTime; function startTrack() { myTime = new Date(); } function stopTrack(str) { var diff = new Date().getTime() - myTime.getTime(); println(str + ' time in ms: ' + diff); } function trackFunction(desc, func, times) { var i; if (!times) times = 1; startTrack(); for (i=0; i<times; i++) { func(); } stopTrack('(' + times + ' times) ' + desc); } var TIMES = 1000000; trackFunction('new rect classic', function() { new Rectangle(2,3); }, TIMES); trackFunction('rect classic (without new)', function() { Rectangle(2,3); }, TIMES); Yields (in Chrome): (1000000 times) new rect classic time in ms: 33 (1000000 times) rect classic (without new) time in ms: 368 (1000000 times) new rect classic time in ms: 35 (1000000 times) rect classic (without new) time in ms: 374 (1000000 times) new rect classic time in ms: 31 (1000000 times) rect classic (without new) time in ms: 368

    Read the article

< Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >