Search Results

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

Page 116/391 | < Previous Page | 112 113 114 115 116 117 118 119 120 121 122 123  | Next Page >

  • C++ Why am I unable to use an enum declared globally outside of the class it was declared in?

    - by VGambit
    Right now, my project has two classes and a main. Since the two classes inherit from each other, they are both using forward declarations. In the first object, right underneath the #include statement, I initialize two enums, before the class definition. I can use both enums just fine inside that class. However, if I try to use those enums in the other class, which inherits from the first one, I get an error saying the enum has not been declared. If I try to redefine the enum in the second class, I get a redefinition error. I have even tried using a trick I just read about, and putting each enum in its own namespace; that didn't change anything.

    Read the article

  • Conceptual inheritance implementation

    - by TheSENDER
    Hi there, I'm writing a spatial data structure and I have a doubt about what's the best NODE implementation. According to my design I have an abstract node entity and three classes which inherit from it: EMPTYNODE, FULLNODE, INTERNALNODE. The first one has no particular data. The second one has 1 reference to a generic element. The third one has 2 references to other nodes. I have found several ways to implement this situation (that I have already coded) but I can't decide what's the best. The first solution that I have found is to use a single class Node that potentially performs all the operation in this way: private static class Node { private Elem elem = null; private Node left = null, right = null; public Elem getElem() { assert isFull(); return elem; } public boolean isEmpty() { return elem == null && left == null; } public boolean isFull() { return elem != null; } public boolean isInternal() { return elem == null && left != null; } } The second solution is to write an explicit division by classes where every class offers only its methods. Obviously in this way we are obliged to perform several casts to the node objects. private static abstract class Node { public abstract boolean isEmpty(); public abstract boolean isFull(); public abstract boolean isInternal(); } private static class FullNode extends Node{ private ITriangle elem; @Override public boolean isEmpty() { return false; } @Override public final boolean isFull() { return true; } @Override public final boolean isInternal() { return false; } public Elem getElem() { return elem; } } The third one solution is to use the inheritance allowing every classes to offer all the methods, but the object type should by check by "isEmpty()" and similar methods. In case of wrong call we'll throw an exception. private static abstract class Node { public abstract boolean isEmpty(); public abstract boolean isFull(); public abstract boolean isInternal(); public abstract Elem getElem(); } private static class Empty extends Node{ @Override public boolean isEmpty() { return true; } @Override public final boolean isFull() { return false; } @Override public final boolean isInternal() { return false; } @Override public Elem getElem() { throw new AssertionError(); } } What do you think about these three solutions? Which one would you use? Any other ideas? Thanks for your help. Every idea will be appreciated.

    Read the article

  • How to infer the type of a derived class in base class?

    - by enzi
    I want to create a method that allows me to change arbitrary properties of classes that derive from my base class, the result should look like this: SetPropertyValue("size.height", 50); – where size is a property of my derived class and height is a property of size. I'm almost done with my implementation but there's one final obstacle that I want to solve before moving on, to describe this I will first have to explain my implementation a bit: Properties that can be modified are decorated with an attribute There's a method in my base class that searches for all derived classes and their decorated properties For each property I generate a "property modifier", a class that contains 2 delegates: one to set and one to get the value of the property. Property Modifiers are stored in a dictionary, with the name of the property as key In my base class, there is another dictionary that contains all property-modifier-dictionaries, with the Type of the respective class as key. What the SetPropertyValue method does is this: Get the correct property-modifier-dictionary, using the concrete type of the derived class (<- yet to solve) Get the property modifier of the property to change (e.g. of the property size) Use the get or set delegate to modify the property's value Some example code to clarify further: private static Dictionary<RuntimeTypeHandle, object> EditableTypes; //property-modifier-dictionary protected void SetPropertyValue<T>(EditablePropertyMap<T> map, string property, object value) { var property = map[property]; // get the property modifier property.Set((T)this, value); // use the set delegate (encapsulated in a method) } In the above code, T is the Type of the actual (derived) class. I need this type for the get/set delegates. The problem is how to get the EditablePropertyMap<T> when I don't know what T is. My current (ugly) solution is to pass the map in an overriden virtual method in the derived class: public override void SetPropertyValue(string property, object value) { base.SetPropertyValue((EditablePropertyMap<ExampleType>)EditableTypes[typeof(ExampleType)], property, value); } What this does is: get the correct dictionary containing the property modifiers of this class using the class's type, cast it to the appropiate type and pass it to the SetPropertyValue method. I want to get rid of the SetPropertyValue method in my derived class (since there are a lot of derived classes), but don't know yet how to accomplish that. I cannot just make a virtual GetEditablePropertyMap<T> method because I cannot infer a concrete type for T then. I also cannot acces my dictionary directly with a type and retrieve an EditablePropertyMap<T> from it because I cannot cast to it from object in the base class, since again I do not know T. I found some neat tricks to infere types (e.g. by adding a dummy T parameter), but cannot apply them to my specific problem. I'd highly appreciate any suggestions you may have for me.

    Read the article

  • How do I dynamically define an instance variable?

    - by Moses
    Hi everyone, I have two classes (class1 and class2) that just store data, no methods. I have a third class that has an instance variable that, depending on some user input, will be set to one of the two classes. So, in the third class I declare the variable generically as NSObject *aClass; and during runtime set it to whatever it should be. aClass = [[Class1 alloc] init]; // or aClass = [[Class2 alloc] init]; However, when I try to access fields from aClass NSString *str = aClass.field1; It gives me the error: request for member 'field1' in something not a structure or a union. Field1 is declared in both class1 and class2. When I try to cast aClass aClass = (Class1 *) aClass; it gives the same error. What am I doing wrong, is there a better way to do this?

    Read the article

  • Java ME Application running fine in Emulator but crashing when deployed to N70. Any way to identify

    - by sana
    I have developed a Java ME application for CLDC platform. It works fine when executed in an emulator. But when i deploy it to my N70 phone the application doesn't start at all in the phone. In my application there are some 14 classes and am creating an instance of each and putting them in the vector on application start. The classes just have one variable and 2 methods. Can this creating of lot of instances be the reason for its crashing? Is there any way I can find out the reason why the application is not able to start in the phone?

    Read the article

  • Class Library Project VS App_Code - Pros / Cons?

    - by rockinthesixstring
    I currently use the App_Code folder for all of my classes, and for me (for now) it seems to be working just fine. I have however been considering making the switch over to a Class Library Project inside my Solution instead of the App_Code folder. Can anyone tell me the pros and cons of doing this? One thought I had was with regards to testing my web app. If I use a Class Library, do I have to compile it every time I want to tweak/test? Obviously in the App_Code folder I don't have to since all of the Classes compile at runtime.

    Read the article

  • Why does PHP 5.2 disallow abstract static class methods?

    - by Artem Russakovskii
    After enabling strict warnings in PHP 5.2, I saw a load of strict standards warnings from a project that was originally written without strict warnings: Strict Standards: Static function Program::getSelectSQL() should not be abstract in Program.class.inc The function in question belongs to an abstract parent class Program and is declared abstract static because it should be implemented in its child classes, such as TVProgram. I did find references to this change here: Dropped abstract static class functions. Due to an oversight, PHP 5.0.x and 5.1.x allowed abstract static functions in classes. As of PHP 5.2.x, only interfaces can have them. My question is: can someone explain in a clear way why there shouldn't be an abstract static function in PHP?

    Read the article

  • WCF interoperability with WSDL proxy and performance consideration advise.

    - by user194917
    I'm essentially writing a broker service. The requirement is that I write an API that acts as an intermediary broker between our in-house developed services and a 3rd party provided API. The intention being that my API abstract the actual communication with the 3rd party API from our internal systems. The architect on the project chose WCF as the communication framework. The problem is that 70 percent of our subscriber applications are written in .Net 2 and as such have no access to the class libraries required to implement a WCF proxy. The end result being that our proxy classes are loosely based on the code auto generated by the WSDL tool as opposed to the SvcUtil tool. My question is, although I have no issues implementing the required proxy classes using basicHttp as the actual binding and using the WSDL tool, are there any special considerations that I need to take into account in this scenario? I.E proxy optimizations and the like. Thanks in advance.

    Read the article

  • Play! Framework - Can my view template be localised when rendering it as an AsyncResult?

    - by avik
    I've recently started using the Play! framework (v2.0.4) for writing a Java web application. In the majority of my controllers I'm following the paradigm of suspending the HTTP request until the promise of a web service response has been fulfilled. Once the promise has been fulfilled, I return an AsyncResult. This is what most of my actions look like (with a bunch of code omitted): public static Result myActionMethod() { Promise<MyWSResponse> wsResponse; // Perform a web service call that will return the promise of a MyWSResponse... return async(wsResponse.map(new Function<MyWSResponse, Result>() { @Override public Result apply(MyWSResponse response) { // Validate response... return ok(myScalaViewTemplate.render(response.data())); } })); } I'm now trying to internationalise my app, but hit the following error when I try to render a template from an async method: [error] play - Waiting for a promise, but got an error: There is no HTTP Context available from here. java.lang.RuntimeException: There is no HTTP Context available from here. at play.mvc.Http$Context.current(Http.java:27) ~[play_2.9.1.jar:2.0.4] at play.mvc.Http$Context$Implicit.lang(Http.java:124) ~[play_2.9.1.jar:2.0.4] at play.i18n.Messages.get(Messages.java:38) ~[play_2.9.1.jar:2.0.4] at views.html.myScalaViewTemplate$.apply(myScalaViewTemplate.template.scala:40) ~[classes/:na] at views.html.myScalaViewTemplate$.render(myScalaViewTemplate.template.scala:87) ~[classes/:na] at views.html.myScalaViewTemplate.render(myScalaViewTemplate.template.scala) ~[classes/:na] In short, where I've got a message bundle lookup in my view template, some Play! code is attempting to access the original HTTP request and retrieve the accept-languages header, in order to know which message bundle to use. But it seems that the HTTP request is inaccessible from the async method. I can see a couple of (unsatisfactory) ways to work around this: Go back to the 'one thread per request' paradigm and have threads block waiting for responses. Figure out which language to use at Controller level, and feed that choice into my template. I also suspect this might not be an issue on trunk. I know that there is a similar issue in 2.0.4 with regards to not being able to access or modify the Session object which has recently been fixed. However I'm stuck on 2.0.4 for the time being, so is there a better way that I can resolve this problem?

    Read the article

  • Best approach to creating a database driven Java website?

    - by Craig Whitley
    I'm fairly new to programming and new to java, but I'd like to jump in the deep end with a little database driven website project. I've read quite a lot about requirements in the 'real world' requesting experience with Spring and Hibernate, so I have those installed on netbeans and a project created (if I hit run I get the default spring page). Now I just need a little guidance as to where to start designing my app (please tell me if I'm getting in a bit too over my head for a beginner!). Should I start off with my classes? - create all my classes as they map to my database tables and decide which attributes and methods each will require? Can anyone suggest any good books for maybe.. making a java based website from scratch (i.e. from design right through to deployment) that might be useful for a beginner? Any help appreciated thanks.

    Read the article

  • What is the pythonic way to add type information to an object's attributes?

    - by Tikitu
    I'm building classes where I know the types of the attributes, but Python of course doesn't. While it's un-pythonic to want to tell it, supposing I do want to, is there an idiomatic way to do so? Why: I'm reading in serialised data (without type information) involving objects-nested-inside-objects. It's easy to put it into nested dictionaries, but I want it in objects of my class-types, to get the right behaviours as well as the data. For instance: suppose my class Book has an attribute isbn which I will fill with an ISBNumber object. My serialised data gives me the isbn as a string; I would like to be able to look at Book and say "That field should be filled by ISBNumber(theString)." Bonus glee for me if the solution can be applied to classes I get from someone else without editing their code.

    Read the article

  • Connecting data to a GUI - OOP

    - by tau
    I have an application with several graphs and tables on it. I worked fast and just made classes like Graph and Table that each contained a request object (pseudo-code): class Graph { private request; public function setDateRange(dateRange) { request.setDateRange(dateRange); } public function refresh() { request.getData(function() { //refresh the display }); } } Upon a GUI event (say, someone changes the date range dropdown), I'd just call the setters on the Graph instance and then refresh it. Well, when I added other GUI elements like tables and whatnot, they all basically had similar methods (setDateRange and other things common to the request). What are some more elegant OOP ways of doing this? The application is very simple and I don't want to over-architect it, but I also don't want to have a bunch of classes with basically the same methods that are just routing to a request object. I also don't want to set up each GUI class as inheriting from the request class, but I'm open to any ideas really.

    Read the article

  • Preprocessor Conditionals

    - by Mike
    I was wondering if it would be possible to have a define which changes values at some point in the code be used in a conditional. Basically something like this: //////////////////////////////////////////// SomeFile.cpp #define SHUTDOWN false while(window->isOpen()) { if(SHUTDOWN) window->close(); // Rest of the main loop } //////////////////////////////////////////// SomeOtherFile.cpp if(Escape.isPressed()) { #undef SHUTDOWN #define SHUTDOWN true } Thus causing the app to close. If it's not, would having a function like RenderWindow* getWindow() { return window; } and then calling if(Escape.isPressed()) getWindow()->close(); The best way to do it? I'd rather not go that route because the classes that are calling the key event are members of the class controlling the main loop and the window, so I'd have to set pointers to the containing class in the smaller classes to call getWindow() and it just seems like a more complicated method. But if I can't do it with preprocessor directives I'll just have to use pointers to the parent class.

    Read the article

  • Enterprise Library Validation Block - Should validation be placed on class or interface?

    - by Robert MacLean
    I am not sure where the best place to put validation (using the Enterprise Library Validation Block) is? Should it be on the class or on the interface? Things that may effect it Validation rules would not be changed in classes which inherit from the interface. Validation rules would not be changed in classes which inherit from the class. Inheritance will occur from the class in most cases - I suspect some fringe cases to inherit from the interface (but I would try and avoid it). The interface main use is for DI which will be done with the Unity block.

    Read the article

  • How can a class's memory-allocated address be determined from within the contructor?

    - by Jim Fell
    Is it possible to get the memory-allocated address of a newly instantiated class from within that class's constructor during execution of said constructor? I am developing a linked list wherein multiple classes have multiple pointers to like classes. Each time a new class instantiates, it needs to check its parent's list to make sure it is included. If I try to do something like this: MyClass() // contructor { extern MyClass * pParent; for ( int i = 0; i < max; i++ ) { pParent->rels[i] == &MyClass; // error } } I get this error: error C2275: 'namespace::MyClass' : illegal use of this type as an expression Any thoughts or suggestions would be appreciated. Thanks.

    Read the article

  • A tool to determine jar dependencies based on existing code?

    - by geoffeg
    Is there a tool that can determine .jar dependencies given a directory of .jar files and a separate directory of java source code? I need to generate Eclipse .classpath files based on an existing code base that doesn't have any dependencies defined. To be more specific, I've been given a large codebase consisting of a dozen or so J2EE-style projects and a single directory of jar files. My client uses a custom development and build framework that is just too arcane for me to use and get any real work done. The projects do not have any information about their dependencies, either between projects or to jar libraries. I would expect this tool would have to spin through each jar file, indexing the classes available in that file and then go through each file in the project source code tree and match up the dependencies, possibly writing out a .classpath file with the required jar files. I realize this is a rather simplistic view of the operation, as duplicate classes among the jar files and such might make things more difficult.

    Read the article

  • How to store multiple variables from a File Input of unknown size in Java?

    - by AlphaOmegaStrife
    I'm a total beginner with my first programming assignment in Java. For our programming assignment, we will be given a .txt file of students like so: 3 345 Lisa Miller 890238 Y 2 <-(Number of classes) Mathematics MTH345 4 A Physics PHY357 3 B Bill Wilton 798324 N 2 English ENG378 3 B Philosophy PHL534 3 A Dandy Goat 746333 Y 1 History HIS101 3 A" The teacher will give us a .txt file on the day of turning it in with a list of unknown students. My problem is: I have a specific class for turning the data from the file into variables to be used for a different class in printing it to the screen. However, I do not know of a good way to get the variables from the input file for the course numbers, since that number is not predetermined. The only way I can think of to iterate over that unknown amount is using a loop, but that would just overwrite my variables every time. Also, the teacher has requested that we not use any JCL classes (I don't really know what this means.) Sorry if I have done a poor job of explaining this, but I can't think of a better way to conceptualize it. Let me know if I can clarify. Edit: public static void analyzeData() { Scanner inputStream = null; try { inputStream = new Scanner(new FileInputStream("Programming Assignment 1 Data.txt")); } catch (FileNotFoundException e) { System.out.println("File Programming Assignment 1 Data.txt could not be found or opened."); System.exit(0); } int numberOfStudents = inputStream.nextInt(); int tuitionPerHour = inputStream.nextInt(); String firstName = inputStream.next(); String lastname = inputStream.next(); String isTuitionPaid = inputStream.next(); int numberOfCourses = inputStream.nextInt(); String courseName = inputStream.next(); String courseNumber = inputStream.next(); int creditHours = inputStream.nextInt(); String grade = inputStream.next(); To show the methods I am using now, I am just using a Scanner to read from the file and for Scanner inputStream, I am using nextInt() or next() to get variables from the file. Obviously this will not work when I do not know exactly how many classes each student will have.

    Read the article

  • Info on Seam's EntityQuery?

    - by Shadowman
    I've been working with Seam and JPA/Hibernate for quite some time, but have just started looking at making use of the EntityHome and EntityQuery classes more. EntityHome seems relatively straightforward in terms of what it is and how I can leverage it. But, EntityQuery is a bit less clear. I understand the ability to grab, for example, a list containing all of a given entity. However, I've also seen some examples using a RESTRICTIONS array. How exactly is this used? Are the OR conditions or AND conditions? Can anyone give me some more detailed information as to how EntityQuery is intended to be used? I've checked the few books I have on Seam and JPA, but none of them really reference the EntityQuery classes. It seems like I very useful mechanism, and I'd like to get some more use out of them if I can. Thanks!

    Read the article

  • Put specific tds from a table row into edit using jQuery (then update w/ ajax)

    - by bbqsauced
    I'm somewhat new to jQuery, so I could use some help here. This is my issue: I have a php script outputting a dynamic table. Each row has an "edit" button, plus some other fields. Only 3 of those need to be turned into an input box. The edit button should only put that specific row into "edit mode." I got as far as assigning each row a unique class by adding a number to the end of it. I have been able to use jQuery to change all of the rows into edit mode, but I need it to be specific to a row. An example row would have classes like name0, price0, and desc0. The next row would go on to classes name1, price1, and desc1 (for the fields that need changed). How can I reference these values and pass them to jQuery so it processes an event on just those elements?

    Read the article

  • What is the right way to pass class parameters to a method

    - by Schneider
    Let's suppose I have three classes A, B and C public class A { public int A1; public string A2; } public class B { public char B1; public double B2; public decimal B3; } public class C { public string DoSomething(A a, B b) { var a1 = a.A1; var b2 = b.B2; var b3 = b.B3; // DoSomething return string.Empty; } } If DoSomething() is using just some fields of the A and B classes, do you prefer to pass the whole object in parameters or create an intermediate class that has just the needed fields by the DoSomething method ?

    Read the article

  • Files mapping architecture

    - by user326198
    I need to know How I can achieve this goal by classes : we have two different applications in the company (App1 , App2) Appl can export xml with know items ( ID , Name) we need app2 to import this data but App2 display different items (CarID, CarName) and this items defined like this with the mapping info <CarID> <Mapping name="ID"/> </CarID> <CarNAme> <Mapping name="Name"/> </CarNAme>" How I can achieve this as classes or ARCHITECTURE , i will develop this with c# I need one interface because we may support different type of files not just xml

    Read the article

  • Should every class have its own namespace?

    - by thehouse
    Something that has been troubling me for a while: The current wisdom is that types should be kept in a namespace that only contains functions which are part of the type's non-member interface (see C++ Coding Standards Sutter and Alexandrescu or here) to prevent ADL pulling in unrelated definitions. Does this imply that all classes must have a namespace of their own? If we assume that a class may be augmented in the future by the addition of non-member functions, then it can never be safe to put two types in the same namespace as either one of them may introduce non-member functions that could interfere with the other. The reason I ask is that namespaces are becoming cumbersome for me. I'm writing a header-only library and I find myself using classes names such as project::component::class_name::class_name. Their implementations call helper functions but as these can't be in the same namespace they also have to be fully qualified!

    Read the article

  • Writing Ruby Libraries - hiding methods from outside the module

    - by JP
    Hi all, I'm writing a Ruby library which has a module with a bunch of classes inside it. Many of these classes need to be usable and modifiable by calling scripts, but I don't want (some of) the initializers to be visible/callable: module MyLib class Control def initialize # They can use this end def do_stuff Helper.new('things') end end class Helper # Shouldn't be visible def initialize(what) @what = what end def shout @what end end end c = MyLib::Control.new h = c.do_stuff p h.shout # => "things" # ^ All of this is desired # v This is undesirable p MyLib::Helper.new('!') # => <MyLib::Helper @what='!'> If it's a simple thing, then I'd also appreciate the generated RDoc not even include the .new method for the Helper class either. Any ideas? Thanks for reading!

    Read the article

< Previous Page | 112 113 114 115 116 117 118 119 120 121 122 123  | Next Page >