Search Results

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

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

  • Entity Framework .. partial constructor

    - by adamjellyit
    Hi .. I intend to extend the constructors of some of the entities in my Entity Framework (4). However how do I ensure that my constructor is run after the model has run its. i.e. I want to ensure that the the object holds the data from the database before I work on it in my constructor.

    Read the article

  • Can I join 2+ styles together into a superstyle?

    - by Kurru
    Hi I was looking to join 2 styles together to make a super style for easy use and customisation of my page. Is it possible to define something like this? (if so how) .bold { font-weight: bold;} .color1 {color: white;} .boldColor {.bold; .color1;} where .boldColor is effectively .boldColor {font-weight:bold; color:white;} I want this so that I can have styles thoughout the page and be able to easily change the colors in many places in 1 place. I'm currently using <p class="bold color"> but some of my class defs are becoming long so I'd like to be able to use <p class="boldColor"> Thanks

    Read the article

  • Java Passing variables around classes

    - by nazerb
    I am new to java and am trying to pass variables like in the following example from one class to another, im wondering is this possible and how i would go about it if it is. As this code does not work as it is not static. Main Class public class testAll { public static void main(String[] args) { One one = new One(); Two two = new Two(); } } The first class: public class One { public int test = 4; public int getTest() { return this.test; } } The second class: public class Two { public void value() { System.out.print("Var is: " + One.getTest()); } } Thanks, Naz

    Read the article

  • How should I structure my repository classes?

    - by Innogetics
    I am new to DDD. In my mini-project, I have a structure that looks like this (different from the actual names): EntryClassificationGroup EntryClassification Entry EntryType Should I have just one repository class for all these 4 entities, since they are all related? Or should I have individual repositories for each one?

    Read the article

  • classes in obj.c

    - by palominoz
    @interface MainViewController : UIViewController < FlipsideViewControllerDelegate { } I am quite new to object oriented languages & especially obj.c. I need to use addressbook framework within this class.Apple documentation suggests this code: @interface ViewController : UIViewController < ABPeoplePickerNavigationControllerDelegate {} I was wondering how to use at the same time FlipSideControllerDelegate & ABPeoplePickerControllerDelegate. In fact I really can't understand what i am doing:)

    Read the article

  • C++ struct, public data members and inheritance

    - by Marius
    Is it ok to have public data members in a C++ class/struct in certain particular situations? How would that go along with inheritance? I've read opinions on the matter, some stated already here http://stackoverflow.com/questions/952907/practices-on-when-to-implement-accessors-on-private-member-variables-rather-than http://stackoverflow.com/questions/670958/accessors-vs-public-members or in books/articles (Stroustrup, Meyers) but I'm still a little bit in the shade. I have some configuration blocks that I read from a file (integers, bools, floats) and I need to place them into a structure for later use. I don't want to expose these externally just use them inside another class (I actually do want to pass these config parameters to another class but don't want to expose them through a public API). The fact is that I have many such config parameters (15 or so) and writing getters and setters seems an unnecessary overhead. Also I have more than one configuration block and these are sharing some of the parameters. Making a struct with all the data members public and then subclassing does not feel right. What's the best way to tackle that situation? Does making a big struct to cover all parameters provide an acceptable compromise (I would have to leave some of these set to their default values for blocks that do not use them)?

    Read the article

  • Java compiler rejects variable declaration with parameterized inner class

    - by Johansensen
    I have some Groovy code which works fine in the Groovy bytecode compiler, but the Java stub generated by it causes an error in the Java compiler. I think this is probably yet another bug in the Groovy stub generator, but I really can't figure out why the Java compiler doesn't like the generated code. Here's a truncated version of the generated Java class (please excuse the ugly formatting): @groovy.util.logging.Log4j() public abstract class AbstractProcessingQueue <T> extends nz.ac.auckland.digitizer.AbstractAgent implements groovy.lang.GroovyObject { protected int retryFrequency; protected java.util.Queue<nz.ac.auckland.digitizer.AbstractProcessingQueue.ProcessingQueueMember<T>> items; public AbstractProcessingQueue (int processFrequency, int timeout, int retryFrequency) { super ((int)0, (int)0); } private enum ProcessState implements groovy.lang.GroovyObject { NEW, FAILED, FINISHED; } private class ProcessingQueueMember<E> extends java.lang.Object implements groovy.lang.GroovyObject { public ProcessingQueueMember (E object) {} } } The offending line in the generated code is this: protected java.util.Queue<nz.ac.auckland.digitizer.AbstractProcessingQueue.ProcessingQueueMember<T>> items; which produces the following compile error: [ERROR] C:\Documents and Settings\Administrator\digitizer\target\generated-sources\groovy-stubs\main\nz\ac\auckland\digitizer\AbstractProcessingQueue.java:[14,96] error: improperly formed type, type arguments given on a raw type The column index of 96 in the compile error points to the <T> parameterization of the ProcessingQueueMember type. But ProcessingQueueMember is not a raw type as the compiler claims, it is a generic type: private class ProcessingQueueMember <E> extends java.lang.Object implements groovy.lang.GroovyObject { ... I am very confused as to why the compiler thinks that the type Queue<ProcessingQueueMember<T>> is invalid. The Groovy source compiles fine, and the generated Java code looks perfectly correct to me too. What am I missing here? Is it something to do with the fact that the type in question is a nested class? (in case anyone is interested, I have filed this bug report relating to the issue in this question) Edit: Turns out this was indeed a stub compiler bug- this issue is now fixed in 1.8.9, 2.0.4 and 2.1, so if you're still having this issue just upgrade to one of those versions. :)

    Read the article

  • Compiling C++ when two classes references one another

    - by Omry
    I am trying to write a simple wrapper around a connection pointer that will return it to the pool when the wrapper is destroyed. but it wont compile because the ConnectionPool and AutoConn need each other to be declared. I tried to use forward deceleration but it didn't work. how do I solve this? (using g++) class Connection {}; class ConnectionPool { Connection *m_c; public: AutoConn getConn() { return AutoConn(this, m_c); // by value } void releaseConnection(Connection *c) { } }; class AutoConn { ConnectionPool* m_pool; Connection *m_connection; public: AutoConn(ConnectionPool* pool, Connection *c) : m_pool(pool), m_connection(c) {} ~AutoConn() { m_pool->releaseConnection(m_connection); } };

    Read the article

  • How to implement callback methods 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

  • When I overload the assignment operator for my simple class array, I get the wrong answer I espect

    - by user299648
    //output is "01234 00000" but the output should be or what I want it to be is // "01234 01234" because of the assignment overloaded operator #include <iostream> using namespace std; class IntArray { public: IntArray() : size(10), used(0) { a= new int[10]; } IntArray(int s) : size(s), used(0) { a= new int[s]; } int& operator[]( int index ); IntArray& operator =( const IntArray& rightside ); ~IntArray() { delete [] a; } private: int *a; int size; int used;//for array position }; int main() { IntArray copy; if( 2>1) { IntArray arr(5); for( int k=0; k<5; k++) arr[k]=k; copy = arr; for( int j=0; j<5; j++) cout<<arr[j]; } cout<<" "; for( int j=0; j<5; j++) cout<<copy[j]; return 0; } int& IntArray::operator[]( int index ) { if( index >= size ) cout<<"ilegal index in IntArray"<<endl; return a[index]; } IntArray& IntArray::operator =( const IntArray& rightside ) { if( size != rightside.size )//also checks if on both side same object { delete [] a; a= new int[rightside.size]; } size=rightside.size; used=rightside.used; for( int i = 0; i < used; i++ ) a[i]=rightside.a[i]; return *this; }

    Read the article

  • Beginner questions regarding Python classes.

    - by Andy
    Hi. I am new to Python so please don't flame me if I ask something too noobish :) 1. Consider I have a class: class Test: def __init__(self, x, y): self.x = x self.y = y def wow(): print 5 * 5 Now I try to create an object of the class: x = Test(3, 4) This works as expected. However, when I try to call the method wow(), it returns an error, which is fixed by changing wow() to: def wow(self) Why do I need to include self and if I don't, what does the method mean?2. In the definition of __init__: def __init__(self, x, y): self.x = x self.y = y Why do I need to declare x and y, when I can do this: def __init__(self): self.x = x self.y = y I hope I am being clear... Thanks for your time.

    Read the article

  • AsyncTask, inner classes and Buttons states

    - by Intern John Smith
    For a musical application (a sequencer), I have a few buttons static ArrayList<Button> Buttonlist = new ArrayList<Button>(); Buttonlist.add(0,(Button) findViewById(R.id.case_kick1)); Buttonlist.add(1,(Button) findViewById(R.id.case_kick2)); Buttonlist.add(2,(Button) findViewById(R.id.case_kick3)); Buttonlist.add(3,(Button) findViewById(R.id.case_kick4)); Buttonlist.add(4,(Button) findViewById(R.id.case_kick5)); Buttonlist.add(5,(Button) findViewById(R.id.case_kick6)); Buttonlist.add(6,(Button) findViewById(R.id.case_kick7)); Buttonlist.add(7,(Button) findViewById(R.id.case_kick8)); that I activate through onClickListeners with for example Buttonlist.get(0).setActivated(true); I played the activated sound via a loop and ifs : if (Buttonlist.get(k).isActivated()) {mSoundManager.playSound(1); Thread.sleep(250);} The app played fine but I couldn't access the play/pause button when it was playing : I searched and found out about AsyncTasks. I have a nested class PlayPause : class PlayPause extends AsyncTask<ArrayList<Button>,Integer,Void> in which I have this : protected Void doInBackground(ArrayList<Button>... params) { for(int k=0;k<8;k++) { boolean isPlayed = false; if (Buttonlist.get(k).isActivated()) { mSoundManager.playSound(1); isPlayed = true; try {Thread.sleep(250); } catch (InterruptedException e) {e.printStackTrace();}} if(!isPlayed){ try {Thread.sleep(250);} catch (InterruptedException e) {e.printStackTrace();} } } return null; } I launch it via Play.setOnClickListener(new PlayClickListener()); with PlayClickListener : public class PlayClickListener implements OnClickListener { private Tutorial acti; public PlayClickListener(){ super(); } @SuppressWarnings("unchecked") public void onClick(View v) { if(Tutorial.play==0){ Tutorial.play=1; Tutorial.Play.setBackgroundResource(R.drawable.action_down); acti = new Tutorial(); Tutorial.PlayPause myPlayPause = acti.new PlayPause(); myLecture.execute(Tutorial.Buttonlist); } else { Tutorial.play=0; Tutorial.lecture.cancel(true); Tutorial.Play.setBackgroundResource(R.drawable.action); } } } But it doesn't work. when I click on buttons and I touch Play/Pause, I have this : 07-02 11:06:01.350: E/AndroidRuntime(7883): FATAL EXCEPTION: AsyncTask #1 07-02 11:06:01.350: E/AndroidRuntime(7883): Caused by: java.lang.NullPointerException 07-02 11:06:01.350: E/AndroidRuntime(7883): at com.Tutorial.Tutorial$PlayPause.doInBackground(Tutorial.java:603) 07-02 11:06:01.350: E/AndroidRuntime(7883): at com.Tutorial.Tutorial$PlayPause.doInBackground(Tutorial.java:1) And I don't know how to get rid of this error. Obviously, the Asynctask doesn't find the Buttonlist activated status, even if the list is static. I don't know how to access these buttons' states, isPressed doesn't work either. Thanks for reading and helping me !

    Read the article

  • template static classes across dynamic linked libraries

    - by user322274
    Hello, I have a templated class with a static value, like this: template <class TYPE> class A{ static TYPE value; }; in the code of a dll I assign the static value: code of DLL_1 A<float>::value = 2.0; I wish the value to be shared by all the dlls I'm using, i.e. I want that: code of DLL_2 printf("value on DLL_2 %f",A<float>::value); print out "2.0" any clues? thx

    Read the article

  • Assign multiple css classes to a table element in Rails

    - by Eric K
    I'm trying to style a table row using both cycle and a helper, like shown: <tr class= <%= cycle("list-line-odd #{row_class(item)}", "list-line-even #{row_class(item)}")%> > However, when I do this, the resulting HTML is: <tr class = "list-line-odd" lowest-price> with the return from the helper method not enclosed in the quotes, and therefore not recognized. Here's the helper I'm using: def row_class(item) if item.highest_price > 0 and item.lowest_price > 0 and item.highest_price != item.lowest_price if item.current_price >= item.highest_price "highest-price" elsif item.current_price <= item.lowest_price "lowest-price" end end end I must be missing something obvious, but I just can't figure out how to wrap both the result of cycle and the helper method return in the same set of quotes. Any help would be greatly appreciated!

    Read the article

  • Python: confused with classes, attributes and methods in OOP

    - by user1586038
    A. Am learning Python OOP now and confused with somethings in the code below. Question: 1. def init(self, radius=1): What does the argument/attribute "radius = 1" mean exactly? Why isn't it just called "radius"? The method area() has no argument/attribute "radius". Where does it get its "radius" from in the code? How does it know that the radius is 5? """ class Circle: pi = 3.141592 def __init__(self, radius=1): self.radius = radius def area(self): return self.radius * self.radius * Circle.pi def setRadius(self, radius): self.radius = radius def getRadius(self): return self.radius c = Circle() c.setRadius(5) """ B. Question: In the code below, why is the attribute/argument "name" missing in the brackets? Why was is not written like this: def init(self, name) and def getName(self, name)? """ class Methods: def init(self): self.name = 'Methods' def getName(self): return self.name """

    Read the article

  • How can I reverse ruby's include function.

    - by Glen
    I'll explain what i'm looking for in code as thats probably the most succinct: module Mixin def method puts "Foo" end end class Whatever include Mixin end w = Whatever.new w.method => "Foo" # some magic here w2 = Whatever.new w.method => NoMethodError I had tried just undefining the Mixin module using remove_const, but this doesn't seem to make any difference to Whatever. I had assumed that #include just added a reference to the module into the class's method resolution chain - but this behaviour doesn't agree with that. Can anyone tell me what include actually does behind the scenes, and how to reverse this?

    Read the article

  • Is it possible to create custom methods in entity classes in linq to sql

    - by doekman
    I have a table Site in SQL with (amongst others) three properties idReviewer1, idReviewer2, idReviewer3. Now I would like to create a methods on the entity class of Site to check if a user is a reviewer: partial class Site { public bool IsReviewer(int idUser) { return idReviewer1 == idUser || idReviewer2 == idUser || idReviewer3 == idUser; } } and I use it like this: return from s in db.Sites where s.IsReviewer(user) select s; However, Linq to SQL doesn't know how to translate this to SQL. I get the following error message: Method 'Boolean IsReviewer(Int32)' has no supported translation to SQL. I'd rather not write this: return from s in db.Sites where idReviewer1 == idUser || idReviewer2 == idUser || idReviewer3 == idUser select s; Is there any way to put this functionality in one place, without resorting to SQL?

    Read the article

  • C++ static classes & shared_ptr memory leaks

    - by HardCoder1986
    Hello! I can't understand why does the following code produce memory leaks (I am using boost::shared_ptr with static class instance). Could someone help me? #include <crtdbg.h> #include <boost/shared_ptr.hpp> using boost::shared_ptr; #define _CRTDBG_MAP_ALLOC #define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) static struct myclass { static shared_ptr<int> ptr; myclass() { ptr = shared_ptr<int>(NEW int); } } myclass_instance; shared_ptr<int> myclass::ptr; int main() { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); return 0; }

    Read the article

  • What if I made an explicit reference to 'this' for use inside an inner class?

    - by badp
    So far, I've used this approach to access this from the scope of an inner class: class FooManagementWindow extends JFrame { JButton rejectFoo; //... void getFooAcceptingPanel(){ //... final FooManagementWindow referenceToThis = this; rejectFoo = new JButton("Reject"); rejectFoo.addEventListener(new EventListener() { @Override public void actionPerformed(ActionEvent arg) { referenceToThis.setEnabled(false); //this requires a network call //... referenceToThis.setEnabled(true); //the user may resume his work } }); //... } } However, I just learned that instead of declaring referenceToThis, a direct reference is kept for me as: FooManagementWindow.this I have no reason to think my less standard approach may lead to errors or weird corner cases. Or are there?

    Read the article

  • 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

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