class

Rails: class' id / object_id changes during same request

I have been having a problem when I try to compare two Rails models. They should evaluate as the same, but the way ActiveRecord implements == is causing it to fail. What's even stranger is the unit tests are passing. Suppose a User has many Posts, and Posts has many Comments. User also has_many comments. (and this is comparing two obje...

Java Object Class

consider the statement : Every class has a super class [ True/ False ] I feel it should be false as Object is the base for all which do not have super class. What should be the proper reply. ...

What is a Class in python, what does it do, why is it needed?

Possible Duplicate: Do I correctly understand what a class is? Before you rant and rage and scream at me, understand that I tried searching everywhere, from google to this very site on what exactly a class in python is. I have found definitions of sorts, but have never been able to understand them fully. So here's the question...

Linkage of class names

$3.5 - "In addition, a member function, static data member, class or enumeration of class scope has external linkage if the name of the class has external linkage." Any inputs on what does it mean by 'if the name of the class has external linkage'? Is the hint on 'local classes' (which probably don't have any linkage) as co...

How to use same named class in PHP without namespacing?

I have a problem, where I have two third party libraries classes that I have to extend and use together. But both have the same naming convention and two class name end up having the same name. Since I cannot extend two classes, I don't know how to fix them, how to create a wrapper against one. I cannot use PHP Namespaces as the PHP ver...

Why doesn't the 'toast' message work, in Android? Cannot fix bug, please help!

Hi, Imagine I have the following code that runs as a background processor for an android application: public class Background extends Service { public void popup (String message, int duration) { Toast.makeText(this, message, duration).show(); } class BackgroundChecker extends TimerTask { public vo...

Android: using SharedPreferences in a library

I made a library that I use across my app. I want it to access some settings that are stored in the shared preferences. This is a shortened version of my library: package com.android.foobar; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Lib { int now; public Lib() { ...

Transforming a c# class into a visual control

Hi, I new to c# and windows form programming. Here is the problem i am trying to solve. I have to write an application that uses an multiple instance of an ActiveX control. Therefore, I dragged as many control as necessary to my Form. Now my problem is that i'd like to add some personalised methods to this activeX. The logical solution...

[PHP] Initializing class with bad input makes it unusable but object is still existent

If I want to create a new object that needs certain informations like a product id or something like that but the input is bad how can I elegant manage such a case? class Product { function __construct($id) { if(is_invalid_id($id)) { return false; } } } If I initialize it this way I still get an object (since retur...

C++ class ordering

I'm starting to play around with C++, coming from C and Objective C (and a bit of Java). I thought a good place to start building my skills is by writing a simple hash table from scratch, using linked lists for collisions. So I started out by writing the skeletons for each class. class HashTable { public: ... private: .....

Convert from Object to Original Class

I'm storing a instance of Entry class in an Object. Entry newentry = new Entry(j, 0.0); Object test = newentry; How can I convert the test Object back into an Entry class to access the Entry class method getValue()? ...

How save implement class in python?

I have instance of the my class. I want to save implementation of class with instance's pickle copy in file. After, I want to use this instance to another computer where there is no implementation of the my class. I don't want to save text of implementation manually. How can I do this? ...

SugarCRM: Create NOTE with Attachment without SOAP?

Hello all, I've got this custom button on Lead Editview that when clicked on generates (via AJAX) an invoice number and a PDF bearing the same number. In the next step, the routine uses SOAP to loopback to Sugar and creates a Note (along with the PDF as attachment). My question is can I avoid this SOAP call and use some other inter...

Advantages of an empty class in C++

What could be the possible advantages/uses of having an empty class? P.S: This question might sound trivial to some of you but it is just for learning purpose and has no practical significance. FYI googling didn't help. ...

Whats the meaning of 'static' when declaring a function

this is the code from the tutorial book. class user { // return if username is valid format public static function validateUsername($username){ return preg_match('/^[A-Z0-9]{2,20}$/i', $username); } } i wonder, what is the function of static? it's too bad the book i read didn't explain it :( ...

Defaults constructors, why my class seems to have three? When compilers treats classes like structures?

I always thought, that there are only two defaults construcors: constructor with no arguments, and copy construtor. But today I wrote something like this: First I wanted to make sure that in C++ initialization of structures in c-style is still valid.. struct Foo{ int a; bool b; char* c; double d; }; //.. Foo arr[2]={{0...

passing values from model to view in CI

Hey guys, I have this library in CI that retrieves my latest twitter updates. It has a function that sends my latest updates as objects to my controller. I would like to show these twitter updates on the footer of my page, so they're visible at all times. Now my question is how I call these directly from a view? I know this is not a g...

How should i handle public properties?

Within my application i have a PUBLIC customer class... Public Class Customer Public Name As String Public Surname As String End Class Then i decided to use LINQ to SQL within my application. After adding the MyDatabase.dbml class, errors showed up since LINQ creates public properties too <Column(Storage:="_Name", DbType:="NV...

Overriding "initialize" in Ruby Ncurses::WINDOW class?

I have following code to try and alter the default Ruby Ncurses behavior: #!/usr/bin/env ruby require 'logger' require 'rubygems' require 'ncurses' class Ncurses::WINDOW def initialize( height, width, starty, startx ) w = super( height, width, starty, startx ) w.clear w.move(0,0) w.addstr('first psot') ...

PHP class causing error

I'm getting this really bad error. I tried copying the example classes off PHP.net. The class worked but I cant seem to get it to include right. My index file includes the users.class.php and then the content.php which has the call to the class. Error: Fatal error: Class 'A' not found in X:\xxxxx\xxxx\xxxxx\content.php on line ...