问题列表 - 第47207页

用Java在类之间传递变量!

我是学习Java的初学者.我有两节课,

public class myClassA {
    //It contains the main function

    yourClass tc = new yourClass();

    .... many codes...

    public void printVariable()
    {
        // print here
    }

}


class yourClass {

    void I_AM_a_button_press()  // function
    {
        // I want to call printVariable() in myClassA here, But how?
    }
}
Run Code Online (Sandbox Code Playgroud)

如何调用另一个类中定义的方法?

java

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

C++/CLI IEnumerable和IEnumerator实现

有没有人有一个如何在C++/CLI中实现IEnumerable和IEnumerator的有效的分步示例?或者,是否有人知道如何修复MS Connect中的以下代码,这些代码无法在Visual Studio 2005中编译?

http://connect.microsoft.com/VisualStudio/feedback/details/101089/how-to-implement-ienumerable-t-and-ienumerable-c-cli

using namespace System;
using namespace System::Collections::Generic;

generic <class T>
public ref struct MyArray : public IEnumerable<T>
{    

    MyArray( array<T>^ d )
    {
        data = d;
    }
    ref struct enumerator : IEnumerator<T>
    {
        enumerator( MyArray^ myArr )
        {
            colInst = myArr;
            currentIndex = -1;
        }

        bool MoveNext()
        {
            if( currentIndex < colInst->data->Length - 1 )
            {
                currentIndex++;
                return true;
            }
            return false;
        }

        property T Current
        {
            T get()
            {
                return colInst->data[currentIndex];
            }
        };
        // This …
Run Code Online (Sandbox Code Playgroud)

ienumerable ienumerator c++-cli

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

gcc堆栈优化

嗨,我有一个关于gcc(或g ++)可能的堆栈优化的问题..

FreeBSD下的示例代码(这里的UNIX差异是否重要?):

void main() {
   char bing[100];
   ..
   string buffer = ....;
   ..
}
Run Code Online (Sandbox Code Playgroud)

我在gdb中找到的这个程序的coredump是bing的地址实际上低于那个缓冲区(即&bing [0] <&buffer).

我认为这完全与教科书中的相反.是否有一些编译器优化以这种方式重新组织堆栈布局?

这似乎只是可能的解释,但我不确定..

如果你感兴趣的话,coredump是由于bing缓冲区溢出缓冲区(但这也确认了&bing [0] <&buffer).

谢谢!

c++ optimization gcc g++

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

Python类表示的方法

我知道有方法__repr____str__存在来给出类实例的正式和非正式表示.但是对于类对象是否也存在等价物,因此当打印类对象时,可以显示它的一个很好的表示?

>>> class Foo:
...     def __str__(self):
...         return "instance of class Foo"
...
>>> foo = Foo()
>>> print foo
instance of class Foo
>>> print Foo
__main__.Foo
Run Code Online (Sandbox Code Playgroud)

python class instance representation

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

实现HTTP代理以克服跨站点AJAX请求限制(?)

我有一个Spring-MVC webapp(3.0.5-RELEASE),它需要从另一个子域(通过AJAX从客户端/浏览器)访问另一个webapp的JSON webservices.

我过去通过以下方式解决了这个问题:

  1. 编写一个代理请求的简单控制器,使用Apache Commons HttpClient处理请求.因此,克服了大多数浏览器的跨站点/跨源请求安全限制

  2. 在服务器端实现JSONP服务(在调用我们自己的JSON服务时) - 并非总是可行

在JSONP不可能的情况下,是否有更好的方法(1.)?

和/或

有没有一个库可以为我处理这个?所以我不必HttpClient自己编写所有代码 - 它不是很多代码,但我想知道我是否(非常)重新发明了这个轮子.

java ajax proxy spring spring-mvc

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

什么是所选链接背景颜色的Android Style属性?

我有一个TextView,我通过Linkify动态添加可点击链接(使用自定义TransformFilter).一切都很好.我现在要做的是在点击链接时更改链接的背景颜色.在CSS中,它将通过:active伪选择器完成.

我想我可以在styles.xml中指定它,但我不知道参数名称是什么.

android android-layout

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

按钮不会显示在navigationBar项目中

我已经创建了一个基于导航的应用程序模板的项目,并做了一些工作并运行它.

我预计如果我触摸一个单元格,新的视图将显示,新的图标(返回按钮)也将显示在导航栏项目上.

但由于某种原因,"后退按钮"不会自动添加.可能是什么问题?

以下是我的代码.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // Navigation logic may go here -- for example, create and push another view controller.
    MessageView *detailViewController = [[MessageView alloc] initWithNibName:@"MessageView" bundle:nil];

    NSDictionary* aMessage = [m_tableData objectAtIndex:indexPath.row];
    detailViewController.m_message = [[NSDictionary alloc] initWithDictionary:aMessage];

    // Pass the selected object to the new view controller.
    [self.navigationController pushViewController:detailViewController animated:YES];
    [detailViewController release];
}
Run Code Online (Sandbox Code Playgroud)

iphone uinavigationcontroller

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

我何时需要在C#中通过COM查询的接口上调用Marshal.ReleaseComObject

我一直在使用一些DirectShow接口来使用C#和DirectShow.Net播放数字电视(DVB-T).我最近遇到了运行时错误COM object that has been separated from its underlying RCW cannot be used.

此错误发生在以下行:

_guideData = _transportInformationFilter as IGuideData;

_transportInformationFilter 是IBaseFilter类型,是以前通过DirectShow.Net实用程序函数分配的COM对象.

我认为错误是由于_transportInformationFilter某种程度上过早释放,我跟踪它到以下方法(删除错误处理):

private void AttachGuideDataEvent()
{
    IConnectionPoint connPoint = null;
    IConnectionPointContainer connPointContainer = null;
    try
    {
        connPointContainer = _transportInformationFilter as IConnectionPointContainer;
        if (connPointContainer == null) /* error */

        var guideDataEventGuid = typeof (IGuideDataEvent).GUID;
        connPointContainer.FindConnectionPoint(ref guideDataEventGuid, out connPoint);
        if (connPoint == null) /* error */

        int cookie;
        connPoint.Advise(this, out cookie);
        if (cookie == 0) /* error …
Run Code Online (Sandbox Code Playgroud)

c# com interop

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

如何检查数组是否为空?

如何检查数组是否为空?我这样做了:

if not self.table[5] is None:
Run Code Online (Sandbox Code Playgroud)

这是正确的方法吗?

python

62
推荐指数
5
解决办法
16万
查看次数

使用 Javascript 按钮切换 CSS 悬停元素

是否可以使用 Javascript 来切换悬停时更改的元素。我想构建一个按钮,它允许 div 从两种不同的状态改变:(1)当 div 没有悬停时和(2)当 div 悬停时。

任何建议如何做到这一点?

谢谢!

技术委员会

html javascript css hover

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