? I guess Apple is already supporting GC in obj c 2.0. Of coz you have a
choice whether or not to enable in Xcode.
Guess LZ was talking about the guy implementing GC in obj c.
int* LinearSuffixSort(char*& inputString, int& stringLength);
Modify the statement:
cout << LinearSuffixSort(fileName,7) << endl;
to
int i=0;
cout << LinearSuffixSort(fileName,i) << endl;
This is because the function prototype is
int* (char*& , int&);
Whenever you want to reference to som obj, you have to allocate memory for
that obj first.
It's mapping issue:
WARN:
System.IndexOutOfRangeException: Unable to find specified column in result
set
at Oracle.DataAccess.Client.OracleDataReader.GetOrdinal(String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[]
names, ISessionImplementor session, Object owner)
at NHibernate.Type.ManyToOneType.Hydrate(IDataReader rs, String[] names,
ISessionImplementor session, Object owner)
at ... 阅读全帖
SomeClass obj;
Object param;
try{
obj = (SomeClass) param;
System.out.println("Yes, it is a instance of SomeClass");
}catch(ClassCastException e){
System.out.println("No, it isn't.");
}
You can call obj.getClass() to get the Class object for obj.
(quite a tongue twister isn't it)
But you'll have to make sure each of the classes you need to copy
has a default constructor, otherwise you'll still end up checking
classes.
Well, this is placing lock on obj. There is no such thing as code to be
protected, what this saying is really
obj logically cover the access right of the resources which should
not be concurrently accessed. and the following code need to access
these resources.
thread
(this)? what does it mean, for design.
Depend on if you want to have finer control of resources. If you want to
update a HashMap instance variable, for example, you would only care if
reading/writing to
As BulletTooth said,
the default impl of equals is
public boolean equals(Object obj) {
return (this == obj);
}
If u don't override, u will always get "false"...
2 is an interesting point, but I have never heard of that. Does that mean if
Object obj=new Object(),
then the Object is moved to some other memory address because of system
memory operations, the obj reference would be changed also? Is there any
example or reference material for this?
the nasty thing about jmock is that whenever I want to mock a dependent
object, I have to abstract out the object creation,
and turn a statment like
MyClass obj = new MyClass();
into
MyClass obj = createMyClass();
while production code has
MyClass createMyClass() { return new MyClass();}
and mock code has
MyClass createMyClass() { return instance_var_mock_myclass;}
I end up having a lot of createXXX() methods in each class implemented,
furthermore, clover would complain that the createXXX() them
All set cares uniqueness and equals() determine whether two object are
identical.
但是我test 了下
import java.util.HashSet;
public class testT {
private String name;
public testT(String name){
this.name=name;
}
public boolean equals(Object o){
if(!(o instanceof testT))return false;
testT person=(testT)o;
return person.name.equals(this.name);
}
public static void main(String[] args){
HashSet hs=new HashSet();
testT p1= new testT("jing");
... 阅读全帖
原来java里有balanced的BST, 比C++的好用些,就是接口太多了,记不住。
写了一个求2d overlap矩形面积的题,
核心代码没多少,code都是定义各种结构各种override各种comparator去了:
public class EPI_14_20_3 {
static class Rectangle {
public int xBeg;
public int xEnd;
public int yBeg;
public int yEnd;
public Rectangle(int xb, int xe, int yb, int ye) {
xBeg = xb;
xEnd = xe;
yBeg = yb;
yEnd = ye;
}
}
What happens when these statements are compiled?
Loan loan = new Loan(amount, months);
Object obj = loan;
obj.calculatePayments();
Answer
a.
A compile-time error occurs because the Object object can’t invoke the
calculatePayments method
b.
A compile-time error occurs because the Object object can’t reference a
Loan object without a cast
c.
These statements will compile without errors
static library?
If so, make sure they all appear in Makefile
e.g, in Makefile
...
obj-m := foo.o
foo-objs := yourcode.o xenomai.a
...
google "kernel module static library" or something similar maybe
This is what i want to run:
arm-none-linux-gnueabi-g++ -ldl -o db4 db4.o -L/somePath/sql3arm -lsqlite3
-lpthread
In makefile
LIBS = -L/somePath/sql3arm -lsqlite3 -lpthread
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
when i run it, it's running with lib options
arm-none-linux-gnueabi-g++ -o db4 db4.o
Any suggestions pls, thanks very much !
Your variable LIBS get overriden some where.
You can add debug line like
LIBS = -L/somePath/sql3arm -lsqlite3 -lpthread
$(info LIBS = $(LIBS))
$(TARGET): $(OBJS)
$(info LIBS = $(LIBS))
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
To see if the LIBS get changed before invoking CXX
# [Q: What does the following do? ]
link object file with lib if it exists
$(COMMAND): $(OBJS) $(MAKEFILE)
$(CC) -o $(COMMAND) $(OBJS) $(LDFLAGS) $(LIBS)
# [Q: What is LIBS? ]
I don't see LIBS defined
# [Q: What does the following do? ]
sum_up_down.o : sum_up_down.cpp $(MAKEFILE)
$(CC) $(CFLAGS) $(WARNFLAGS) -c sum_up_down.cpp -o sum_up_down.o
compile to object file
以下程序似乎是对的,在Visual Studio 2005里面却报错:
error C2660: 'B::Add' : function does not take 1 arguments
#include
using namespace std;
class A
{
public:
int Add(int X) {return Add(X, 1);};
private:
virtual int Add(int X, int Y) {return X+Y;};
};
class B: public A
{
private:
int Add(int X, int Y) {return X-Y;};
};
int main()
{
B Obj;
cout << Obj.Add(5);
return 0;
}
难道B不能用base clas A的那个public function吗?
用不同函数名就没问题了
#include
using namespac
以下程序似乎是对的,在Visual Studio 2005里面却报错:
error C2660: 'B::Add' : function does not take 1 arguments
#include
using namespace std;
class A
{
public:
int Add(int X) {return Add(X, 1);};
private:
virtual int Add(int X, int Y) {return X+Y;};
};
class B: public A
{
private:
int Add(int X, int Y) {return X-Y;};
};
int main()
{
B Obj;
cout << Obj.Add(5);
return 0;
}
难道B不能用base clas A的那个public function吗?
用不同函数名就没问题了
#include
u
For obj.proc(5):
1. calculat the address of obj, and push this address onto the stack (or
load it into a registary). Member function requires "this" pointer.
2. push 5 onto the stack (or load it into a registary).
3. call C::proc(int). Assuming compiler is smart enough to de-virtual the
call to proc.
For ptr->proc(5):
1. push the value of ptr onto the stack (or load it into a registary).
2. push 5 onto the stack (or load it into a registary).
3. get the enry address from vtable.
4. call C::proc
In python 2.5,
from __future__ import with_statement
You can write a special objective working with the `with' statement, such as
with SomeClass() as obj:
## do you things here
## when leaving the current context normally or by exception,
## the obj's speciall method will be invoked and do the house
## cleaning job.
right. The webservices call returns something like
myobject:hash(ea214653)
How to interpret this obj. By wsdl? Or is there any function I
Can use to parse the obj. Info? Thanks.