问题列表 - 第31237页

Should I be using inheritance?

This is more of a subjective question, so I'm going to preemptively mark it as community wiki.

Basically, I've found that in most of my code, there are many classes, many of which use each other, but few of which are directly related to each other. I look back at my college days, and think of the traditional class Cat : Animal type examples, where you have huge inheritance trees, but I see none of this in my code. My …

oop inheritance class-design

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

jQuery:如何显示元素并同时使用高亮效果?

我在页面上有两个元素.

<div id="a">content</div>
<div id="b" style="display:none">different content</div>
Run Code Online (Sandbox Code Playgroud)

当我点击当前显示的时候div,我想隐藏它并显示另一个.这很容易做到:

$('#a').hide();
$('#b').show();
Run Code Online (Sandbox Code Playgroud)

但现在我想更进一步,突出显示元素.我认为它会涉及effect("highlight"),但我无法让它发挥作用.我该如何实现这一目标?

jquery

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

获取Git中(可能删除的)文件的历史记录/日志

如何查看特定文件的历史记录(可能已在当前主干中删除)?

另外,你建议使用什么diff工具?

git

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

从python中不同类中的类调用方法

假设我有这个代码:

class class1(object):
    def __init__(self):
        #don't worry about this 


    def parse(self, array):
        # do something with array

class class2(object):
    def __init__(self):
        #don't worry about this 


    def parse(self, array):
        # do something else with array
Run Code Online (Sandbox Code Playgroud)

我希望能够从 class2 调用 class1 的解析,反之亦然。我知道用 C++ 这可以很容易地通过做

class1::parse(array)
Run Code Online (Sandbox Code Playgroud)

我将如何在 python 中做等效的事情?

python

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

常规字符串和逐字字符串之间有什么区别?

我有一个Resharper的试用版,它总是建议我将常规字符串切换为逐字字符串.有什么不同?

c# resharper

156
推荐指数
5
解决办法
7万
查看次数

Degrees symbol (as in Degrees Celsius/Fahrenheit) in a TextView

Is there a way to include the small circular degrees symbol to a TextView? This would be for temperature readings, as in degrees Celsius or Fahrenheit. I'm wondering if anyone has done this programmatically before.

android textview

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

是否有可能在.NET中捕获访问冲突异常?

我有什么可以做的AccessViolationException吗?它是由我无法控制的非托管DLL引发的.

.net exception-handling unmanaged

29
推荐指数
3
解决办法
2万
查看次数

QGraphicsScene中的文本

如何在QGraphicsScene的某个坐标中写文字?我试图这样做,但没有成功.文字有边框,但字母内部是白色,我不能让它变成黑色.

QPainterPath path;

QFont font;
font.setPixelSize(50);

path.addText(100, 50, font,  tr("Hello World!!!"));
path.setFillRule();

m_graphScen->addPath(path);
Run Code Online (Sandbox Code Playgroud)

text qgraphicsview

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

当我尝试使用我的结构时,为什么会出现错误?

我有一个结构在Header文件中定义我正在使用的类,我试图在类的其中一个方法中使用Struct.看起来基本上是这样的:

struct example
{
     double a;
     int b;
     ...
};
Run Code Online (Sandbox Code Playgroud)

在我的类定义上面的标题中,然后在cpp文件中,我有:

void exampleclass::test(){

    struct example *teststruct;
    teststruct->a = 0; //This line causes a access violation

}
Run Code Online (Sandbox Code Playgroud)

为什么我在这里收到错误?我确定我在这里做了一些完全错误的事情,我必须说我是一个巨大的结构新秀.

c++ structure

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

C++"智能指针"模板,可自动转换为裸指针但无法显式删除

我正在使用一个非常大的遗留C++代码库,它仍然是无名的.作为遗留代码库,它会在整个地方传递原始指针.但我们正在逐步尝试对其进行现代化,因此也有一些智能指针模板.这些智能指针(与Boost的scoped_ptr不同)具有对原始指针的隐式转换,因此您可以将其中一个传递给一个采用原始指针而无需编写的例程.get().一个很大的缺点是你也可能在一个delete声明中意外地使用一个,然后你有一个双重免费的bug,这可能是一个真正的痛苦追踪.

有没有办法修改模板,使其仍然具有对原始指针的隐式转换,但如果在delete语句中使用,则会导致编译错误?像这样:

#include <my_scoped_ptr>

struct A {};
extern void f(A*);

struct B
{
    scoped_ptr<A> a;

    B();
    ~B();
};

B::B()
    : a(new A)
{
    f(a); // this should compile
}

B::~B()
{
    delete a; // this should NOT compile
}
Run Code Online (Sandbox Code Playgroud)

c++ templates smart-pointers

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