问题列表 - 第34513页

使用new与without实例化对象之间的区别是什么

在C++中,

除了动态内存分配之外,以下两行代码之间是否存在功能差异:

Time t (12, 0, 0); //t is a Time object

Time* t = new Time(12, 0, 0);//t is a pointer to a dynamically allocated Time object
Run Code Online (Sandbox Code Playgroud)

我当然假设定义了一个Time(int,int,int)ctor.我也意识到在第二种情况下,t将需要删除,因为它是在堆上分配的.还有其他区别吗?

c++ constructor new-operator

99
推荐指数
4
解决办法
5万
查看次数

java.sql.SQLException:初始化时出现索引:: 4时缺少IN或OUT参数错误

strInsertQuery="INSERT INTO SYNPACKAGEFREEUSAGEMAPPING (PACKAGEID,SERVICEID,PRIORITY,MAPPINGID,ATTRIBUTEVALUE,FREEUSAGE,UOM,PARAMSTR1,UNITCREDITPOLICYDETAILID) VALUES (?,?,?,?,?,?,?,?,?)";
newPstmt=newCon.prepareStatement(strInsertQuery);
newPstmt.setString(1,strProductId);
              newPstmt.setString(2,strUPGServiceId);
              newPstmt.setInt(3,0);
              if(FieldMappingrs.next())
              {
               newPstmt.setLong(4,FieldMappingrs.getLong(1));
              }
              newPstmt.setString(5,ucpDetailData.getCreditattributevalue());
              for(Iterator itrColUnitCreditDetail=ucpData.iterator();itrColUnitCreditDetail.hasNext();)
       {

        unitCreditData = (UnitCreditDetailData)itrColUnitCreditDetail.next();
        if(ucpDetailData.getUnitcreditpolicydetailid().equals(unitCreditData.getUnitcreditpolicydetailid()))
        {
         debugLog(PackageConstant.PACKAGE_MODULE_NAME,"ServicePackageSessionBean:createFreeUsageServiceDetails() unitCreditData "+ unitCreditData);
                newPstmt.setDouble(6,unitCreditData.getEndvalue());
               }

               debugLog(PackageConstant.PACKAGE_MODULE_NAME,"Insert record successfull"+ ucpDetailData);
              }
              newPstmt.setString(7,ucpDetailData.getUom());
              newPstmt.setString(8,ucpDetailData.getCreditattribute());
              newPstmt.setString(9,ucpDetailData.getUnitcreditpolicydetailid());

              newPstmt.executeUpdate();
Run Code Online (Sandbox Code Playgroud)

java parameters prepared-statement

0
推荐指数
1
解决办法
2万
查看次数

如何在Delphi中使用ManagementObjectSearcher?

我在互联网上找到但我没有得到如何在delphi中使用ManagementObjectSearcher.我的主要问题是我必须在'使用'中添加哪个文件.

我找到了一个代码,但无法让它在我的系统中运行.

delphi wmi delphi-2007

0
推荐指数
1
解决办法
1690
查看次数

Makefile循环依赖

这是我的Makefile:

.PHONY: all homework1
CFLAGS= -g -O0 -Wall -Werror -Wno-unused-function
LDFLAGS= -lm

all : homework1

homework1 : program.tab.o program.lex.o
%.o : %.c
    gcc -o$@ -c $(CFLAGS) $<
%.lex.c : %.lex %.tab.h
    flex -o$@ $<
%.tab.c %.tab.h : %.y
    bison --verbose -o$@ -d $<
Run Code Online (Sandbox Code Playgroud)

每当我尝试编译时,我都会收到警告,make: Circular program.lex <- program.lex.o dependency dropped.我看不出makefile中的program.lex依赖程度program.lex.o.我看到依赖树是如何约4层深,但它看起来不是圆形的.

如何改进我的makefile?

c dependencies makefile circular-dependency

4
推荐指数
3
解决办法
7344
查看次数

如何使用NSPredicate过滤核心数据关系?

假设我有"obj"类型的核心数据对象,它具有属性"propertyA"和与"sub"类型的对象的一对多关系,该对象具有两个属性"propertyB"和"propertyC".

我想获取propertyA等于一个值的所有objs和一个带有propertyB和propertyC set的子obj.

如果它只是propertyA和propertyB,我会这样做

[NSPredicate predicateWithFormat:@"ANY sub.propertyB = %@ AND propertyA == %@", ...];
Run Code Online (Sandbox Code Playgroud)

问题是我无法弄清楚如何添加第二个属性.我只想要至少有一个具有两个属性的子的obj.我尝试了以下,但它不起作用:

[NSPredicate predicateWithFormat:@"ANY (sub.propertyB = %@ AND sub.propertyC) AND propertyA == %@", ...];
Run Code Online (Sandbox Code Playgroud)

我已经尝试过没有ANY,但这也不起作用.我怎样才能做到这一点?

iphone core-data nspredicate

5
推荐指数
1
解决办法
3689
查看次数

Java异常处理机制

在Java中,如果我没有捕获抛出的Exception,那么Thread执行会在其他地方停止,如果我抓住它,那么在catch块之后继续执行Thread.Why以这种方式设计Java异常处理.

谢谢

java multithreading exception-handling exception

1
推荐指数
1
解决办法
1132
查看次数

UNIX 上使用 free() 时 putenv() 的问题

我试图在 UNIX 上通过在此之前连接 str1 和 str2 来使用 putenv() 。我想在环境中添加一个变量或修改一个变量,所以我调用 putenv() (或者我可以调用 setenv() 相同)。

基本上,我收到 str1 和 str2,我创建 str1=str2 并将其作为参数传递到 putenv() 中。

我显示的代码有效,但是当我取消对 free() 调用的注释时,它不会:变量不会为环境添加/修改。

size_t size = strlen(str1) + strlen(str2) + 2; // 2 is for the '\0' and the '='
char *tmp = (char *) malloc(sizeof(char) * size);
char *p;
int pos = 0;

// Copy first word
p = str1;
while (*p != NULL) {
    tmp[pos++] = *p++;
}

// Add the '='
tmp[pos++] = '=';

// Copy …
Run Code Online (Sandbox Code Playgroud)

c unix free memory-management

3
推荐指数
1
解决办法
802
查看次数

使用PHP在SoundCloud中创建播放列表

我正在创建一个音乐网站,我已经集成了SoundCloud API.

现在我想在运行时创建播放列表并将曲目附加到该播放列表.

我的代码如下:

class Soundcloud {

    const VERSION = '1.1';

    public static $urls = array(
        'api' => 'http://api.soundcloud.com/',
        'oauth' => array(
            'access' => 'http://api.soundcloud.com/oauth/access_token',
            'authorize' => 'http://soundcloud.com/oauth/authorize',
            'request' => 'http://api.soundcloud.com/oauth/request_token'
        )
    );

    function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null) {
        $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
        $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);

        if (!empty($oauth_token) && !empty($oauth_token_secret)) {
            $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
        } else {
            $this->token = null;
        }
    }

    function get_authorize_url($token) {
        if (is_array($token)) {
            $token = $token['oauth_token'];
        } …
Run Code Online (Sandbox Code Playgroud)

php audio soundcloud

5
推荐指数
1
解决办法
2245
查看次数

zend headtitle使用zend_navigation

我正在使用zend_navigation来创建菜单.哪个工作正常.现在我正在寻找我是否可以使用headTitle获取当前页面并将其设置为页面标题.有没有办法做到这一点?

要么

我如何使用配置文件(.ini)来创建Pagetitle和元数据?

php zend-framework zend-navigation

3
推荐指数
1
解决办法
2104
查看次数

如何将多个参数传递给线程函数

我已经为一个线程创建了一个函数,但我想将多个参数传递给该函数.

这是我的源代码:

#include "work.h"
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>    // compile with -lpthread

int count = 20;

void* ChildProc(void* arg)
{
    int i;

    for(i = 1; i <= count; i++)
    {   
        printf("%s:%d from thread <%x>\n", arg, i, pthread_self());
        DoWork(i);
    }

    return NULL;
}

void ParentProc(void)
{
    int i;

    for(i = count / 2; i > 0; i--)
    {
        printf("Parent:%d from thread <%x>\n", i, pthread_self());
        DoWork(i);
    }
}

int main(void)
{
    pthread_t child;

    pthread_create(&child, NULL, ChildProc, "Child");

    ParentProc();

    pthread_join(child, NULL); …
Run Code Online (Sandbox Code Playgroud)

c unix ubuntu posix

2
推荐指数
1
解决办法
7372
查看次数