reify在Clojure中使用时,如何为构造函数提供表达式?
或者,如何将参数传递给基类构造函数?
我刚刚意识到这个程序编译并运行(gcc版本4.4.5/Ubuntu):
#include <iostream>
using namespace std;
class Test
{
public:
// copyconstructor
Test(const Test& other);
};
Test::Test(const Test& other)
{
if (this == &other)
cout << "copying myself" << endl;
else
cout << "copying something else" << endl;
}
int main(int argv, char** argc)
{
Test a(a); // compiles, runs and prints "copying myself"
Test *b = new Test(*b); // compiles, runs and prints "copying something else"
}
Run Code Online (Sandbox Code Playgroud)
我想知道为什么这个甚至可以编译.我假设(就像在Java中)参数在调用方法/构造函数之前被评估,所以我怀疑这个案例必须由语言规范中的一些"特殊情况"涵盖?
问题:
编辑1:我刚刚意识到我甚至可以写作 int i = i;
编辑2:即使有-Wall …
我正在使用带有连接池数据源的hibernate
<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
<property name="connectionCachingEnabled" value="true" />
<property name="URL">
<value>${jdbc.url}</value>
</property>
<property name="user">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="connectionCacheProperties">
<value>
MinLimit:10
MaxLimit:75
InitialLimit:10
ConnectionWaitTimeout:120
InactivityTimeout:180
ValidateConnection:true
MaxStatementsLimit:0
</value>
</property>
</bean>
<bean id="hibernatePropertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="hibernate.properties"/>
</bean>
<!-- Database Property -->
<bean id="hibernatePropertiesPearl"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.cache.provider_class">MyCacheProvider</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.max_fetch_depth">0</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</prop>
<prop key="hibernate.connection.autocommit">false</prop>
<prop key="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.JBossTransactionManagerLookup
</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
<prop key="hibernate.transaction.auto_close_session">false</prop>
</props>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我可以看到,连接在数据库中成功打开并且工作正常,但过了一段时间我在日志中收到以下错误消息并且服务器刚刚死掉: …
如何使用最新的Xcode构建在iOS 3.1.3中测试应用程序?
是否可以在模拟器中执行此操作?如果没有,是否可以将设备降级到iOS 3.1.3?
我对调试感到非常沮丧,但也许我只是做错了.
当我正在积极开发时,编写一些代码非常麻烦,启动调试器来测试所述代码,等待一分钟让调试器启动,查看浏览器中的页面,停止调试器,编辑代码,冲洗,泡沫,重复一遍.
我可以通过在开发过程中使用CTRL-F5和CTRL-SHIFT-B来解决这个问题,但是我失去了调试器的所有好处.
有没有更好的方法来使用调试器,或者我可以做些什么来快速重建和使用调试器?
谢谢,
凯尔
PS我/我们会编写单元测试,但您还需要在浏览器中测试您的应用程序,所以请不要"如果您的单元测试写得正确,就不应该有这个问题." 评论 ;)
更新
感谢"获得更好的机器"的建议.我不能做那么多.大量的RAM和英特尔SSD.我不需要超过2500美元的机器来编写Web应用程序.
我正在为我正在进行的项目创建一个倒数计时器,我认为尽可能获得最准确的时间非常重要.什么是更准确,更重要的是,最不可改变的服务器时间?
该项目需要几天/小时/分钟/秒,所以如果我可以从服务器获取页面的确切时间,那么我可以将其放入JavaScript变量并从那里开始工作.
我有一个使用双打的C代码.我希望能够在DSP(TMS320)上运行代码.但DSP不支持双精度数,只支持定点数.将代码转换为定点的最佳方法是什么?是否有一个很好的C库用于定点数(实现为整数)?
c signal-processing fixed-point texas-instruments beagleboard
我有个问题.
using (var tran = repository.Session.BeginTransaction())
{
try
{
repository.Save(entity);
tran.Comit();
}
catch(Exception)
{
tran.Rollback();
throw;
}
}
using (var tran = repository.Session.BeginTransaction())
{
try
{
repository.GetById(id);
tran.Comit();
}
catch(Exception)
{
tran.Rollback();
throw;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试在异常之后和tran.rollback()第一个using块中通过ID获取实体时,我得到更新异常.所以NHibernate试图从using第二个using块的第一个块更新实体.
为什么?我做了tran.Rollback().我也必须这样做Session.Clear()吗?
我在python中有一个算法,它为值对创建度量,其中m(v1, v2) == m(v2, v1)(即它是对称的).我有想法写一个词典字典,其中这些值以一种以内存有效的方式存储,以便可以使用任何顺序的键轻松检索它们.我喜欢从事物中继承,理想情况下,我喜欢写一个总是等于的symmetric_dict地方,可能是根据某种排序关系检查哪个v更大然后切换它们以便更小的元素总是首先提到.也就是说,在调用时,dicts的字典会将它们转过来,以便它们实际上存储为s_d[v1][v2]s_d[v2][v1]s_d[5][2] = 4s_d[2][5] = 4,以及检索数据的相同.我也非常开放以获得更好的数据结构,但我更喜欢使用"is-a"关系实现只使用dict并预处理某些函数参数的实现.
我正在为一个对象数组编写一个模板类,称之为arrayobjclass,它包含指向其他对象的指针,特别是我实现中的其他数组.数组也作为对象实现,称之为arrayclass.寻找准备好的最小变化.
当我尝试使用以下行测试我的类时,
g++ main.cpp arrayclass.cpp arrayobjclass.cpp -o arrayobj
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
/tmp/ccEpROXj.o(.text+0x17c): In function `main':
: undefined reference to `arrayobjclass<arrayclass, int>::arrayobjclass(int)'
/tmp/ccEpROXj.o(.text+0x1dc): In function `main':
: undefined reference to `arrayobjclass<arrayclass, int>::addelem(arrayclass*)'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我真的无法理解有什么不对.任何帮助,将不胜感激.如果有帮助,代码的简短相关部分如下.提前致谢!
#include "arrayclass.h"
#include "arrayobjclass.h"
#include <iostream>
// 5 arrays of 10 maxsize each
#define MAXSIZE_array 10
#define NUMB_objs 5
using namespace std;
int main () {
//create a simple array as an arrayclass object
arrayclass * numbers1 = new arrayclass (MAXSIZE_array);
//array of …Run Code Online (Sandbox Code Playgroud) asp.net ×2
c++ ×2
beagleboard ×1
c ×1
c# ×1
clojure ×1
constructor ×1
datetime ×1
debugging ×1
dictionary ×1
fixed-point ×1
hibernate ×1
inheritance ×1
iphone ×1
java ×1
nhibernate ×1
python ×1
reify ×1
rollback ×1
session ×1
testing ×1
transactions ×1
xcode ×1