小编con*_*ice的帖子

如何有两个相互调用C++的函数

我有2个这样的函数,它对if循环进行模糊处理:

void funcA(string str)
{
    size_t f = str.find("if");
    if(f!=string::npos)
    {
        funcB(str);        //obfuscate if-loop
    }
}

void funcB(string str)
{
     //obfuscate if loop
     funcA(body_of_if_loop);     //to check if there is a nested if-loop
}
Run Code Online (Sandbox Code Playgroud)

如果我放在前面,问题funcA就是无法看到funcB,反之亦然.funcBfuncA

非常感谢这里的任何帮助或建议.

c++ mutual-recursion

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

使用上下文调用另一个类的方法

我有一个带有ImageButton的自定义标题栏,它会生成一个对话框,我希望能够在从对话框中选择列表项时在地图(在另一个类中)显示位置(放置itemizedOverlay),并且标题栏和地图在相同的背景.我在某处读到了我可以使用上下文调用另一个类的方法.我怎么能这样做?

public class MyTitleBar extends RelativeLayout{

private Context context;


public MyTitleBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
}

@Override
protected void onFinishInflate() {

    super.onFinishInflate();

    initViews();
}

// set up all the buttons  & clicks
private void initViews() {

    final ImageButton listImgBtn = (ImageButton) findViewById(R.id.more);
    final CharSequence [] listItems = {"Elderly","Events"};

    listImgBtn.setOnClickListener(new  View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(context instanceof UserHome)
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setTitle("List");
                builder.setItems(listItems, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface …
Run Code Online (Sandbox Code Playgroud)

android android-context

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

Java-从两个不同数据类型的ArrayList中获取公共元素

我有两个大小不同的ArrayList。

ArrayList<String> names = new ArrayList<String>();
ArrayList<User> users = new ArrayList<User>();
Run Code Online (Sandbox Code Playgroud)

用户是具有属性名称和地址的对象。我想获取存储在ArrayList用户中的User对象的名称与存储在ArrayList名称中的名称相同的地址。

这可能吗?如果是这样,怎么办?

java compare arraylist object

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

无法使用jquery从html表中删除行

我正在使用jquery添加新行以及删除行.添加部分有效,但删除根本不起作用,我无法弄清楚原因.它会第一次工作,其余的时间它不起作用.具体来说,它唯一可行的时间是我点击第一行的删除.

HTML

<table class="table table-striped table-bordered" id="entryTable">  
            <thead> ...
            </thead> 
            <tbody>
                <tr>
                    <td>...</td>
                    <td>...</td>
                    <td>...</td>
                    <td><a href="#" id="addRow">Add</a><br>
                        <a href="#" id="deleteRow">Delete</a>
                    </td>
                </tr>
            </tbody>
        </table>
Run Code Online (Sandbox Code Playgroud)

jQuery的

var i = 1;
    $("#addRow").click(function(){

        $("table tr:last").clone().find("input, select, textarea").each(function(){
            $(this).val('').attr({
                'id': function(_,id){ return id+i},
                'name': function(_,name){ return name+i},
                'value':''
            });
        }).end().appendTo("table");
        i++;
    });

    $("#deleteRow").click(function(){
        alert("delete clicked")
        $(this).parent().parent().remove();
    });
Run Code Online (Sandbox Code Playgroud)

我试图改变$(this).parent().parent().remove();$(this).closest("tr").remove();但是,这并不正常工作.

我也尝试过这样做<a href="#" onclick="deleteRow(this)">并声明一个函数deleteRow,但这也没有帮助.

肯定会感谢这里的帮助或指点.谢谢.

html javascript jquery

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