小编yPr*_*mer的帖子

在Visual C++中关闭突出显示"event"关键字

我有疑问:如何在Visual C++ 2010中关闭突出显示关键字"事件"?我不使用.net,所以对我来说它不是关键字,我称之为变量"event".

c++ visual-studio-2010 visual-studio

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

为什么这个方法不像我期望的那样调用虚拟?

我想问一下,当我使用没有指针的虚函数时会发生什么?例如:

#include <iostream>
using namespace std;
class Parent
{
 public:
   Parent(int i) { }
   virtual void f() { cout<<"Parent"<<endl; }
};

class Child : public Parent
{
 public:
   Child(int i) : Parent(i) { }
   virtual void f() { Parent::f(); cout<<" Child"<<endl; }
};

int main()
{
    Parent a(2);
    Parent b = Child(2);
    a.f();
    b.f();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

^^为什么不起作用?我在哪里可以找到有关虚拟方法如何工作的内容?

c++ object-slicing

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