How do I go from a Class object to a list of enums generically?
i.e.
public static <T extends Enum> List<T> getList(Class<T> clazz)
I cant find a way to get to the values() method
Hello, I want to do a class thats accepts anything ordered and prints greater. (I'm just learning so I know it's a bit useless)
class PrinterOfGreater[T extends Ordered](val a:T, val b:T){println(a > b)}
I know that it can't be written by this style in scala, but I don't know how to write it properly... Do anybody know?
Suppose you want to throw Exception like this:
'Project with the provided ID cannot be assigned.'
and you don't want to write your custom Exception class. What predefined Exception class would you use for this?
(I'm talking about all classes inheriting from Exception)
How do I create a Zend_Db_Table which returns a different class for each row.?
Example
UserTable has id,name and type
Type contains class names (admin,client,etc...)
The classes admin, client are all subclasses of user
If I call fetch I need to get a admin or client object depending on the corresponding value in the db.
I have a page that has the following div structure:
<div id="name" class="class_name">
How would I style the class?
Like this?
#name .class_name
name .class_name
#name class_name
?
Hi
I new to python and I read from someone else of the example code below:
class A:
def current(self):
data = Data(a=a,b=b,c=c)
return data
class B(A):
#something here
#print data a b c
How do I print out the data a, b, and c?
I want to know how can we open a file dialog from withing a class module in vb6. I know how to do in forms, but I have to open it from within a class module.
When creating a mixed mode class, on compilation the header file complains that it needs to be complied with the /clr switch as it is a mixed mode class, however, I can't see any option to specifically compile that header with /clr from visual studio, and I don't want to set the entire project with a /clr flag,
Does anyone know how I can specify that this header file is compiled correctly with /clr?
Thanks in advance!
Hi ,
Please give me a real time simple example for the below questions :
Where to use interface rather abstract class
Where to use abstract class rather interface
I need code snippet for both .
Which takes low memory and which performs well . Do I need to consider the design aspect also?
What is the conceptual difference not the syntactical difference .
I have a variable called $theclass and it's a string "Home_class". How can I define a class out of that string? The reason I need to do this is that the variable will change and I want to be able to declare the class that the variable is equal to. Is this possible?
Thanks for any help.
hi,
i load a class using
Class.forName(klassname,false,loader)
After this i create an instance using
klass.newInstance();
It returns an object type.I want to cast it to specific type(ie.Klassnamw instance).I used normal casting but it gets hung because it is not resolved during runtime.How can i cast it?Hellp
Hi, when using scaffolding on a controller the views render fine and the app even attempts to insert the data; the problem is that the scaffold is completely ignoring the relations I'm defining in my model class, in fact it's ignoring the class entirely as I can delete the file and the controller still scaffolds and render the crud from the table.
Has this ever happened to you?
What is the difference between the following class methods?
Is it that one is static and the other is not?
Class Test(Object):
def method_one(self):
print "Called method_one"
def method_two():
print "Called method_two"
a_test = Test()
a_test.method_one()
a_test.method_two()
I have a hyper link control and I set the NavigateURL and the ImageURL property at runtime. I also need to set the class of the image tag that it generates but I cannot figure out how I can do that. The solution mentioned here
http://stackoverflow.com/questions/1428879/apply-css-class-to-image-in-asphyperlink
does not work because the image url is hard coded.
any ideas?
Hi,
I have a Android class extending Application to generate some global classes, etc.
It works, in that I can, for example, get the context, etc.
BUT, when I try this:
row = (TextView) findViewById(R.id.list_row_text);
I get
R.id.list_row_text = Class not loaded : <mypackage>.R$id
Any ideas why this is happening?
Thanks
Gerardo
Please advise me the difference between two ways of declaration of java constructor
public class A{
private static A instance = new A();
public static A getInstance() { return instance;
}
public static void main(String[] args) {
A a= A.getInstance();
}
}
AND
public class B{
public B(){};
public static void main(String[] args) {
B b= new B();
}
}
Thanks
Hey all, I'm working on building my own string class with very basic functionality. I am having difficulty understand what is going on with the basic class that I have define, and believe there is some sort of error dealing with the scope occurring. When I try to view the objects I created, all the fields are described as (obviously bad pointer). Also, if I make the data fields public or build an accessor method, the program crashes. For some reason the pointer for the object is 0xccccccccc which points to no where.
How can a I fix this? Any help/comments are much appreciated.
//This is a custom string class, so far the only functions are
//constructing and appending
#include<iostream>
using namespace std;
class MyString1
{
public:
MyString1()
{
//no arg constructor
char *string;
string = new char[0];
string[0] ='\0';
std::cout << string;
size = 1;
}
//constructor receives pointer to character array
MyString1(char* chars)
{
int index = 0;
//Determine the length of the array
while (chars[index] != NULL)
index++;
//Allocate dynamic memory on the heap
char *string;
string = new char[index+1];
//Copy the contents of the array pointed by chars into string, the char array of the object
for (int ii = 0; ii < index; ii++)
string[ii] = chars[ii];
string[index+1] = '\0';
size = index+1;
}
MyString1 append(MyString1 s)
{
//determine new size of the appended array and allocate memory
int newsize = s.size + size;
MyString1 MyString2;
char *newstring;
newstring = new char[newsize+1];
int index = 0;
//load the first string into the array
while (string[index] != NULL)
{
newstring[index] = string[index];
index++;
}
//load the second string
while (s.string[index] != NULL)
{
newstring[index] = s.string[index];
index++;
}
//null terminate
newstring[newsize+1] = '\0';
delete string;
//generate the object for return
MyString2.string=newstring;
MyString2.size=newsize;
return MyString2;
}
private:
char *string;
int size;
};
int main()
{
MyString1 string1;
MyString1 string2("Hello There");
MyString1 string3("Buddy");
string2.append(string3);
return 0;
}
Is there a way to pickle a class definition?
What I'd like to do is pickle the definition (which may created dynamically), and then send it over a TCP connection so that an instance can be created on the other end.
I understand that there may be dependencies, like modules and global variables that the class relies on. I'd like to bundle these in the pickling process as well, but I'm not concerned about automatically detecting the dependencies because it's okay if the onus is on the user to specify them.
How to implement a static function in an abstract class?? Where do I implement this?
class Item{
public:
//
// Enable (or disable) debug descriptions. When enabled, the String produced
// by descrip() includes the minimum width and maximum weight of the Item.
// Initially, debugging is disabled.
static enableDebug(bool);
};
hi..
i want to log messages from multiple classes. the problem is that currently i can log all messages into single file.i want to do this class A should log its messages into ALog.txt and class B should log its messages into BLog.txt
please tell me the sample config file for these settings
For debug reasons, and curiosity, I wish to list all classes loaded to a specific class loader.
Seeing as most methods of a class loader are protected, what is the best way to accomplish what I want?
Thanks!
It is possible to call methods on a class whose interface is not exposed through an .idl file?
Im my particular case I'd like to use the @mozilla.org/gfx/fontmetrics;1 class, whose interface nsIFontMetrics doesn't have a correspondent .idl file.
Why on earth won't this compile? Scala 2.8.0RC3:
Java
public interface X {
void logClick(long ts, int cId, String s, double c);
}
Scala
class Y extends X {
def logClick(ts: Long, cId: Int,sid: java.lang.String,c: Double) : Unit = {
...
}
}
Error
class Y needs to be abstract, since method logClick in trait X of type
(ts: Long,cId: Int,s: java.lang.String,c: Double)Unit is not defined
Hi,
Struct has default access specifier is public where as class has default access specifier is private. So why can't use struct if change default access specifier as private? why class?
Thanks,
kam