Search Results

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

Page 43/391 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • Databinding and Lists in instances of classes

    - by Younes
    I have initialised an instance of a class i have called "Relation" this class also contains a list of "Bills". When i databind this information to a grid, the Relations are showing, tho the Bills ain't. The Relation information is returning in a List and the Bills are inside. Relation cRelation = new Relation(); List<tRelation> relationList = cRelation.getRelations(); a relation has: relation.Bills <== List<tBills>; How to make sure that the list inside the list is also getting showed in the Datagrid?

    Read the article

  • C++ Typing and OOP child classes

    - by Zack
    I'm a bit confused: If I have a base class A, and a class B which extends A, can a variable of the type A hold a value of the type B and vice versa? If yes, why? Aren't they completely different even if B is derived from A? How about type-safety? If this is possible, what things do I have to mind when taking use of this? How would this work out in terms of performance? Note: Sorry if I asked too many questions, just ignore them and just look out for those "marked" with the list decoration dot :) Also, this is not my homework. I'm a hobby programmer and have skills in scripting languages with OOP, yet I'm relatively new to OOP typing in C++.

    Read the article

  • Change update value of property (LINQTOSQL)

    - by Dynde
    Hi... I've got an entity object - Customer, with a property called VATRate. This VATRate is in the form of a decimal (0.25). I wanted to be able to enter a percentage value, and save it in the correct decimal value in the database, so I made this custom property: partial class Customer{ public decimal VatPercent { get{ ... //Get code works fine} set { this.VATRate = (value / 100); } } } And then I just bind this property instead of VATRate in my ASPX editTemplate (formview). This actually works - at least one time, when I debug an update, the value is set correctly one time, and then right after it gets set to the old value. I can't really see why it sets the value twice (and with the old value the second time). Can anyone shed some light on this?

    Read the article

  • Rails - inheritance hierarchy of classes where an subtipe can play two roles

    - by Miquel
    I need to model Owners and Rentees in an application, so you have stuff that is always owned by someone and can be rented for someone else. I first approached this problem with Single Table Inheritance because both types of person will share all attributes, so you would have a model called Person associated to a table people with Owner and Rentee inheriting from Person. The problem is that Single type inheritance discerns subtypes using a field type and therefore a record in the table can represent either an Owner or a Rentee but not both at the same time, while in the real context you can have an Owner which is renting something from another Owner and therefore that person is at the same time an Owner and a Rentee. How would you approach this problem? Would you use separated tables fro owners and rentees? Is there any other type of table inheritance in Rails?

    Read the article

  • How to generalize a method call in Java (to avoid code duplication)

    - by dln385
    I have a process that needs to call a method and return its value. However, there are several different methods that this process may need to call, depending on the situation. If I could pass the method and its arguments to the process (like in Python), then this would be no problem. However, I don't know of any way to do this in Java. Here's a concrete example. (This example uses Apache ZooKeeper, but you don't need to know anything about ZooKeeper to understand the example.) The ZooKeeper object has several methods that will fail if the network goes down. In this case, I always want to retry the method. To make this easy, I made a "BetterZooKeeper" class that inherits the ZooKeeper class, and all of its methods automatically retry on failure. This is what the code looked like: public class BetterZooKeeper extends ZooKeeper { private void waitForReconnect() { // logic } @Override public Stat exists(String path, Watcher watcher) { while (true) { try { return super.exists(path, watcher); } catch (KeeperException e) { // We will retry. } waitForReconnect(); } } @Override public byte[] getData(String path, boolean watch, Stat stat) { while (true) { try { return super.getData(path, watch, stat); } catch (KeeperException e) { // We will retry. } waitForReconnect(); } } @Override public void delete(String path, int version) { while (true) { try { super.delete(path, version); return; } catch (KeeperException e) { // We will retry. } waitForReconnect(); } } } (In the actual program there is much more logic and many more methods that I took out of the example for simplicity.) We can see that I'm using the same retry logic, but the arguments, method call, and return type are all different for each of the methods. Here's what I did to eliminate the duplication of code: public class BetterZooKeeper extends ZooKeeper { private void waitForReconnect() { // logic } @Override public Stat exists(final String path, final Watcher watcher) { return new RetryableZooKeeperAction<Stat>() { @Override public Stat action() { return BetterZooKeeper.super.exists(path, watcher); } }.run(); } @Override public byte[] getData(final String path, final boolean watch, final Stat stat) { return new RetryableZooKeeperAction<byte[]>() { @Override public byte[] action() { return BetterZooKeeper.super.getData(path, watch, stat); } }.run(); } @Override public void delete(final String path, final int version) { new RetryableZooKeeperAction<Object>() { @Override public Object action() { BetterZooKeeper.super.delete(path, version); return null; } }.run(); return; } private abstract class RetryableZooKeeperAction<T> { public abstract T action(); public final T run() { while (true) { try { return action(); } catch (KeeperException e) { // We will retry. } waitForReconnect(); } } } } The RetryableZooKeeperAction is parameterized with the return type of the function. The run() method holds the retry logic, and the action() method is a placeholder for whichever ZooKeeper method needs to be run. Each of the public methods of BetterZooKeeper instantiates an anonymous inner class that is a subclass of the RetryableZooKeeperAction inner class, and it overrides the action() method. The local variables are (strangely enough) implicitly passed to the action() method, which is possible because they are final. In the end, this approach does work and it does eliminate the duplication of the retry logic. However, it has two major drawbacks: (1) it creates a new object every time a method is called, and (2) it's ugly and hardly readable. Also I had to workaround the 'delete' method which has a void return value. So, here is my question: is there a better way to do this in Java? This can't be a totally uncommon task, and other languages (like Python) make it easier by allowing methods to be passed. I suspect there might be a way to do this through reflection, but I haven't been able to wrap my head around it.

    Read the article

  • Is there a way to cause a new C++ class instance to fail, if certain conditions in the contructor ar

    - by Jim Fell
    As I understand it, when a new class is instantiated in C++, a pointer to the new class is returned, or NULL, if there is insufficient memory. I am writing a class that initializes a linked list in the constructor. If there is an error while initializing the list, I would like the class instantiator to return NULL. For example: MyClass * pRags = new MyClass; If the linked list in the MyClass constructor fails to initialize properly, I would like pRags to equal NULL. I know that I can use flags and additional checks to do this, but I would like to avoid that, if possible. Does anyone know of a way to do this? Thanks.

    Read the article

  • Accessing variablss through a different class within the constructor of latter classes of an object

    - by Haxed
    In the code below, I've added two lines that print output. The first line prints junk as usual, but surprisingly the second one gives me a compilation error. Why? class Student { private String name; public Student(String name){ this.name = name; } public String getName(){ return name; } } class StudentServer { public StudentServer(){ Student[] s = new Student[30]; s[0] = new Student("Nick"); // LINE 01: This compiles, although prints junk System.out.println(s[0]); // LINE 02: I get a error called cannot find symbol System.out.println(s[0].getName()); } public static void main(){ new StudentServer(); } } Many Thanks

    Read the article

  • Custom Control in ASP.NET C#

    - by Gal V
    Hello all, I created a simple custom control that only inherits from the Literal control, and doesn't have any extensions yet, code is empty. Namespace: CustomControls Class name: Literal : System.Web.UI.WebControls.Literal Next thing I do is registering this control in the aspx page as following: <%@ Register TagPrefix="web" Namespace="CustomControls" % (I read in few tutorials that this is one of the ways to register it, besides web.config etc.) After all, no intellisence for me, and worse- I get a parse error 'unknown server tag: web' when I try to run the page with the control in it. I used 'create new project' and not new website, in case this info is needed. What could be my problem? Thanks in advance.

    Read the article

  • Controlling when SQL UPDATE is executing on ehcache 'd classes

    - by thomers
    We are using Hibernate and ehcache as 2nd level cache. If I load an entity that is cached (e.g. cache-usage="read-write") and update it, it seems that this immediately results in an SQL UPDATE. (How) Can I influence when this SQL UPDATE happens? hibSession = HibernateUtil.getReadWriteSession(); tx = hibSession.beginTransaction(); User u = (User) hibSession.load(User.class, user_id); u.modify(); hibSession.update(u); tx.commit(); Edit: It seems that setting a CacheMode should have an effect, but each hibSession.update() results in an immediate SQL UPDATE, regardless which CacheMode I set.

    Read the article

  • jquery(selector) how to select the last element from two different classes

    - by Yasir Laghari
    for the following html <div> <div class="col1" > I dont want to select this </div> <div class="col2"> I dont want to select this </div> <div class="col1"> I dont want to select this </div> <div class="col1"> I dont want to select this </div> <div class="col2"> I WANT to select this </div> </div> How do I select the last element with two different class names? Tried using $("col1:last,col2:last) but it gives back 2 elements tried $("col1,col2:last") and this gives all col1 and last of col2

    Read the article

  • Java GC: top object classes promoted (by size)?

    - by Java Geek
    Hello! Please let me know what is the best way to determine composition of young generation memory promoted to old generation, after each young GC event? Ideally I would like to know class names which are responsible say, for 80% of heap in each "young gen - old gen" promotion chunk; Example: I have 600M young gen, each tenure promotes 6M; I want to know which objects compose this 6M. Thank you.

    Read the article

  • Using a part of a class in multiple projects

    - by Axarydax
    I have a set of methods that do some utility work over SQL connection, and until now these have been copied over from project to project. But as time goes on, project numbers have grown and I need to keep these methods in sync in case I find a bug or need to update it. I have managed to get it to the state that SQL access class is a partial class, one part is specific for project and contains wrappers for a specific database. The second part is the common one and contains methods that are used in all project-specific databases. The problem is that now I would have the "utility" class copied over 8 projects, with the same content, but in different namespaces. In C/C++ it would have been simple, because I would just have #included the contents of the file wherever needed. What should I do in C#?

    Read the article

  • GetValue on static field inside nested classes.

    - by Sir Gallahad
    Hi... I have the following class declared. I need to retreive the class structure and the static values without instanciate it. public MyClass() { public static string field = "Value"; public nestedClass() { public static string nestedField = "NestedValue"; } } I've successfuly used GetFields and GetNestedType to recover the class structure and GetValue(null) works fine on field, but not on nestedField. Let me sample: var fi = typeof(MyClass).GetField("field", BindingFlags.Public | BindingFlags.Static); var nt = typeof(MyClass).GetNestedType("nestedClass", BindingFlags.Public); var nfi = nt.GetField("nestedField", BindingFlags.Public | BindingFlags.Static); // All the above references are detected correctly var value = fi.GetValue(null); // until here everything works fine. value == "Value" var nestedValue = nfi.GetValue(null); // this one does not work!! Anyone knows why the last line does not work and how to work around? Thanks.

    Read the article

  • What's the benefit of declaring class functions separately from their actual functionality?

    - by vette982
    In C++, what's the benefit of having a class with functions... say class someClass{ public: void someFunc(int arg1); }; then having the function's actual functionality declared after int main int main() { return 0; } void someClass::someFunc(int arg1) { cout<<arg1; } Furthermore, what's the benefit of declaring the class in a .h header file, then putting the functionality in a .cpp file that #includes the .h file?

    Read the article

  • Do classes which have a vector has a member have memory issues

    - by user263766
    I am just starting out C++, so sorry if this is a dumb question. I have a class Braid whose members are vectors. I have not written an assignment operator. When I do a lot of assignments to an object of the type Braid, I run into memory issues :- 0 0xb7daff89 in _int_malloc () from /lib/libc.so.6 #1 0xb7db2583 in malloc () from /lib/libc.so.6 #2 0xb7f8ac59 in operator new(unsigned int) () from /usr/lib/libstdc++.so.6 #3 0x0804d05e in __gnu_cxx::new_allocator<int>::allocate (this=0xbf800204, __n=1) at /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/../../../../include/c++/4.4.3/ext/new_allocator.h:89 #4 0x0804cb0e in std::_Vector_base<int, std::allocator<int> >::_M_allocate (this=0xbf800204, __n=1) at /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/../../../../include/c++/4.4.3/bits/stl_vector.h:140 #5 0x0804c086 in _Vector_base (this=0xbf800204, __n=1, __a=...) at /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/../../../../include/c++/4.4.3/bits/stl_vector.h:113 #6 0x0804b4b7 in vector (this=0xbf800204, __x=...) at /usr/lib/gcc/i686-pc-linux-gnu/4.4.3/../../../../include/c++/4.4.3/bits/stl_vector.h:242 #7 0x0804b234 in Braid (this=0xbf800204) at braid.h:13 #8 0x080495ed in Braid::cycleBraid (this=0xbf8001b4) at braid.cpp:191 #9 0x080497c6 in Braid::score (this=0xbf800298, b=...) at braid.cpp:251 #10 0x08049c46 in Braid::evaluateMove (this=0xbf800468, move=1, pos=0, depth=2, b=...) I suspect that these memory issues are because the vectors are getting resized. What I want to know is whether objects of type Braid automatically expand when its members expand? he code I am writing is really long so I will post the section which is causing the problems. Here is the relevant section of the code :- class Braid { private : vector<int> braid; //Stores the braid. int strands; vector < vector<bool> > history; vector < vector<bool> > CM; public : Braid () : strands(0) {} Braid operator * (Braid); Braid* inputBraid(int,vector<int>); int printBraid(); int printBraid(vector<vector<int>::iterator>); vector<int>::size_type size() const; ..... ..... } Here is the function which causes the issue :- int Braid::evaluateMove(int move,int pos,int depth,Braid b) { int netscore = 0; Braid curr(*this); curr = curr.move(move,pos); netscore += curr.score(b); while(depth > 1) { netscore += curr.evaluateMove(1,0,depth,b); netscore += curr.evaluateMove(2,0,depth,b); for(int i = 0; i < braid.size();++i) { netscore += curr.evaluateMove(3,i,depth,b); netscore += curr.evaluateMove(4,i,depth,b); netscore += curr.evaluateMove(5,i,depth,b); curr = curr.cycleBraid(); netscore += curr.evaluateMove(6,0,depth,b); } --depth; } return netscore; }

    Read the article

  • [iphone] method created in a seperate class returns "out of scope"

    - by Dror Sabbag
    Hey, I have created a Class (subclass of NSObject) which will hold all my SQLs/dbConnections etc.. in a seperate viewcontroller, i have instantiated the SQL's class and performed some actions, all went trough OK. but. one of my methods in the SQL's class is a method defined as follows: -(NSString *)queryTable:(NSUInteger *)fieldnum //query from db, and assign the field value into "fieldName" dbEntity = fieldName; [fieldName release]; } sqlite3_finalize(statement); } return dbEntity; } dbEntity is defined as NSString, and i have set it as a nonatoimc-retain property @property (nonatomic,retain) NSString *dbEntity; when ever i call this method out from my viewController and debug step by step, i see that the method is running, it is quering from the db as expected, but when it passes the value into dbEntity the values in dbEntity are suddenly "out of scope" that is... if i browse this specific action: dbEntity = fieldName; i can see values inside fieldName, but see "out of scope" in dbEntity. Why is that?!? what is wrong with dbEntity definitions? Any help will be appriciated.

    Read the article

  • How do I write a writer method for a class variable in Ruby?

    - by tepidsam
    I'm studying Ruby and my brain just froze. In the following code, how would I write the class writer method for 'self.total_people'? I'm trying to 'count' the number of instances of the class 'Person'. class Person attr_accessor :name, :age @@nationalities = ['French', 'American', 'Colombian', 'Japanese', 'Russian', 'Peruvian'] @@current_people = [] @@total_people = 0 def self.nationalities #reader @@nationalities end def self.nationalities=(array=[]) #writer @@nationalities = array end def self.current_people #reader @@current_people end def self.total_people #reader @@total_people end def self.total_people #writer #-----????? end def self.create_with_attributes(name, age) person = self.new(name) person.age = age person.name = name return person end def initialize(name="Bob", age=0) @name = name @age = age puts "A new person has been instantiated." @@total_people =+ 1 @@current_people << self end

    Read the article

  • How do I change the class of an object to a subclass of its current class in C++?

    - by Jared P
    I have an array of pointers to a base class, so that I can make those pointers point to (different) subclasses of the base class, but still interact with them. (really only a couple of methods which I made virtual and overloaded) I'm wondering if I can avoid using the pointers, and instead just make an array of the base class, but have some way to set the class to the subclass of my choosing. I know there must be something there specifying the class, as it needs to use that to look up the function pointer for virtual methods. By the way, the subclasses all have the same ivars and layout. Note: the design is actually based on using a template argument instead of a variable, due to performance increases, so really the abstract base class is just the interface for the subclasses, which are all the same except for their compiled code. Thanks

    Read the article

  • [Android] Putting Serializable Classes into SQL?

    - by CaseyB
    Here's the situation. I have a bunch of objects that implement Serializable that I want to store in a SQL database. I have two questions Is there a way to serialize the object directly into the database Is that the best way to do it or should I Write the object out to a formatting String and put it in the database that way and then parse it back out Write each member to the database with a field that is unique to each object

    Read the article

  • Problem with accessing classes from another class.

    - by srikanth rongali
    I have a classA, classB,classC. I have another class classABC; All are CCLayer inherited. I need to call all the classA, classB, classC from classABC. #import <Foundation/Foundation.h> #import "cocos2d.h" @interface classABC : CCLayer { classA *aClass; } @property(nonatomic, retain)classA *aClass; @end #import "classABC" #import "classA.h" #import "classB.h" #import "classC.h" @implementation classABC -(id)init { if( (self = [super init]) ) { ClassA *aClass = [[ClassA alloc]init]; CCScene *aClassS = [CCScene node]; CCLayer * aClassL = [aClass node]; [aClassS addChild: aClassL]; [[CCDirector sharedDirector] setAnimationInterval:60.0/60]; [[CCDirector sharedDirector] replaceScene: aClass]; } return self; } @end But I am not getting the classA displayed. How should I do it ? Thank You.

    Read the article

  • Automatically Add a Prefix to Column Names for @Embeddable Classes

    - by VeeArr
    I am developing a project in which I am persisting some POJOs by adding Hibernate annotations. One problem I am running into is that code like this fails, as Hibernate tries to map the sub-fields within the Time_T onto the same column (i.e. startTime.sec and stopTime.sec both try to map to the colum sec, causing an error). @Entity public class ExampleClass { @Id long eventId; Time_T startTime; Time_T stopTime; } @Embeddable public class Time_T { int sec; int nsec; } As there will be many occurrences like this throughout the system, it would be nice if there was an option to automatically append a prefix to the column name (e.g. make the columns be startTime_sec, startTime_nsec, stopTime_sec, stopTime_nsec), without having to apply overrides on a per-field basis. Does Hibernate have this capability, or is there any other reasonable work-around?

    Read the article

  • printing the instance in Python

    - by kame
    Hello! With this code: class Complex: def __init__(self, realpart, imagpart): self.real = realpart self.imag = imagpart print self.real, self.imag class Circle: def __init__(self, radius): print "A circle wiht the radius", radius, "has the properties:" print "circumference =", 3.14*radius print "area =", 3.14*radius**2 I get this output: >>> Complex(3,2) 3 2 <__main__.Complex instance at 0x01412210> But why does he print the last line?

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >