问题列表 - 第31405页

操纵数据成员(C++)

我有一个方法,以对象作为参数.

调用者和参数都具有相同的成员(它们是同一个类的实例).

在该方法中,比较特定成员,然后,基于此比较,需要操纵参数对象的一个​​成员:

class Object {

   // members

public: 

someMethod (object other) {

   int result;
   member1 - other.member1 = result;
   other.member2 = other.member2 - result;

}
Run Code Online (Sandbox Code Playgroud)

唯一的事情是它实际上并没有将other.member2改变到这个范围之外,并且变更需要是永久性的.

所以是的,对不起:我需要有关指针的建议......我已经在网上和书中看过,但我无法让它发挥作用.我想其中一个人会看到这个,并在大约30秒内知道答案.我有RFTM而且是一个愚蠢的损失.我不鼓励.

感谢大家!

c++ pointers

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

Wordpress:全局禁用wptexturize

我有一个标题为"Paper 10x10"的Wordpress页面.在我的侧边栏导航中,此页面显示为"纸张10×10"(请注意,x由Wordpress进行纹理化,因此x成为乘法符号×).

我安装了插件原始html插件.它只禁用wptexturizing the_content.但导航不在,the_content但在get_sidebar().

我试过remove_filter:

remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
Run Code Online (Sandbox Code Playgroud)

但这也只会禁用内容或摘录的纹理化.

如何wptexturize在Wordpress博客中全局禁用过滤器?

wordpress

4
推荐指数
2
解决办法
3759
查看次数

ColdFusion REGEX - 确定文件的扩展名

我正在寻找一个REGEX来获取文件扩展名.

举个例子:

modocument.doc
modocument.docx
dasddsa.pdf
kdsksdklsadklasdklads.png
ads123.jpg
Run Code Online (Sandbox Code Playgroud)

我需要一个提供3-4个字符扩展名的REGEX,但不会被以下内容所欺骗:

asdadsasdads.jpg.png
Run Code Online (Sandbox Code Playgroud)

并且只能获得如上所示的PNG.

regex coldfusion

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

PHP:尝试通过Cron作业运行脚本时出错

我通过控制面板设置了一个cron作业.我已经通过我的FTP上传了脚本,将其权限设置为777(这样做是否安全?)并在作业中提供了此脚本的路径.现在,该脚本使用依赖脚本来运行作业.混乱?这就是它的样子:

cron.php

<?php require("some_file1.php");
require("file1.php");
require("folder1/file1.php");
require("folder1/file2.php");
require("folder2/file1.php");

//This value is actually received from one of the require files above after come calculations
$get_content = 'This is some value received after calculations.';

mail('Hi', 'email@mydomain.com', $get_content, 'Error');
?>
Run Code Online (Sandbox Code Playgroud)

我选择在我的电子邮件中收到确认Cron作业,这是我收到的错误:

mydomain.com/cron.php: line 1: syntax error near unexpected token `('
mydomain.com/cron.php: line 1: `<?php require("some_file1.php");
'
Run Code Online (Sandbox Code Playgroud)

我尝试与支持人员交谈,但他们对这些技术细节一无所知,目前技术人员无法使用.如果有人可以帮助我,这将是很棒的.

期待您的回复.

谢谢.

php cron

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

自动IllegalArgumentException消息?

我总是检查公共函数的参数,并在出错时抛出异常.(对于私人助手,我使用断言).

像这样:

if( a < 0 || a >= b )
    throw new IllegalArgumentException("'a' must be greater or equal to 0 and 
        smaller than b ");
Run Code Online (Sandbox Code Playgroud)

但是编写这些错误消息总是令我很烦.这条消息对我来说似乎是多余的,因为消息只是对陈述的否定

a < 0 || a >= b
Run Code Online (Sandbox Code Playgroud)

.

我经常会通过重构(在eclipse中)重命名变量,然后消息不会反映更改.或者我改变条件而忘记更改消息.

如果我能写下这样的东西,那就太好了:

assertArgument(a >= 0 && a < b);
Run Code Online (Sandbox Code Playgroud)

这应该引发一个类似的消息的IllegalArgumentException

"violated argument assertion: a >= 0 && a < b."
Run Code Online (Sandbox Code Playgroud)

在C中你可以编写一个宏(实际上在C断言中只是一个宏).有没有一种简单的方法在java中做这样的事情?

谢谢!

java assertions illegalargumentexception

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

抽象泛型类采用本身派生自该类的类型参数

您是否认为创建一个抽象泛型类是一种可接受或不好的做法,该类将类型参数作为一个派生自己的类?

这允许抽象泛型类操作派生类的实例,特别是在必要时创建派生类的new()实例的能力,并且可以帮助避免从派生类派生的具体类中重复代码.

如果"糟糕"你更喜欢处理这种情况的替代方案,你将如何构建下面的代码?

例如:-

    // We pass both the wrapped class and the wrapping class as type parameters 
    // to the generic class allowing it to create instances of either as necessary.

    public abstract class CoolClass<T, U>
        where U : CoolClass<T, U>, new()
    {
        public T Value { get; private set; }
        protected CoolClass() { }
        public CoolClass(T value) { Value = value; }
        public static implicit operator CoolClass<T, U>(T val)
        {
            // since we know the derived type and …
Run Code Online (Sandbox Code Playgroud)

generics abstract-class

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

RemoteViews setLayoutParams?

我想将a的高度设置TextViewWRAP_CONTENT远程.

我怎么会这样做,因为没有remoteviews.setLayoutParams(viewId, param)功能?

我试过remoteviews.setInt.(viewId, "setHeight", -2),但这只是设置TextView为零的高度......

谢谢!

android views textview

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

使用PHP调用__get/__ set/__调用性能问题

我有一个定制的MVC PHP框架,我正在重写,并对性能和魔术方法有疑问.使用框架的模型部分,我在想是否__get/ __setmagic方法会导致太多的性能损失值得使用.我的意思是访问(读取和写入)模型数据将是最常见的事情之一.对于像MVC框架的模型部分这样的大量使用功能,__get/ __setmagic方法的使用是否太大了?

php performance magic-methods

5
推荐指数
2
解决办法
5977
查看次数

使用Maven创建tar.gz存档

我有一个Maven项目,在src/main目录下有一个名为output的子目录.这个文件夹需要打包成tar.gz. 使用程序集插件时如下:

从pom.xml:

<build>
<finalName>front</finalName>
<plugins>
    <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-5</version>
    <configuration>
      <descriptors>
        <descriptor>src/main/assembly/assembly.xml</descriptor>
      </descriptors>
    </configuration>
  </plugin>
  </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

assembly.xml:

<assembly>
    <id>bundle</id> 
    <formats>
        <format>tar.gz</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>src/main/output</directory>
        </fileSet>
</fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)

我的问题是我尝试的结果将是运行tar实用程序本身,这意味着在解压缩时获取输出目录及其所有内容.我得到的是包含所有项目路径的输出文件夹 - name/src/main/output.

maven-2 archive maven-assembly-plugin

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

为什么这个for循环不执行?

我有一个选择器视图控制器来选择化学源和可能的浓度.如果光源没有浓度,它只会提供一个选择器.它由一个NSDictionary源类型名称keys和一个我调用的自定义模型对象填充,Chemical它有四个属性,两个NSString,一个float和一个BOOL.

当我用包含2个组件的字典触发它时,我想从Chemical表示的那个中提取四个值.请注意,我使用前两个属性的值填充选择器,但不包括floatBOOL.我遍历数组中的第一个组件中选择的键,并检查第二个组件中的字符串与键/值数组中chemConcentration每个Chemicals 的属性.当chemConcentration比赛时,我知道我有权利Chemical,我可以将其属性发回.

呼!

问题是,即使我知道我进入for循环,它似乎被跳过了.NSLog在它打印之前的右边,但里面的那个没有. sourceConstantsourceIsLiquid0.0NO

- (IBAction)selectedSourceButton {
    NSLog(@"selectedSourceButton pressed");
    NSInteger sourceRow = [picker selectedRowInComponent:kSourceComponent];
    NSString *selectedSource = [self.sources objectAtIndex:sourceRow];
    NSArray *selectedChemicalGroup = [dictionaryOfSources objectForKey:selectedSource];
    NSInteger concentrationRow = [picker selectedRowInComponent:kConcentrationComponent];
    NSString *selectedConcentration = [[NSString alloc] init];
    float selectedConstant = 0.0;
    BOOL selectedIsLiquid = NO;

    if …
Run Code Online (Sandbox Code Playgroud)

iphone xcode loops objective-c uipickerview

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