virtual

C#抽象类

匿名 (未验证) 提交于 2019-12-02 22:06:11
一、继承 什么是继承 :继承是允许重用现有类去创建新类的过程。分类的原则是一个类派生出来的子类具有这个类的所有非私有的属性。 1 、继承 C# 中的类: C#不支持多重继承,C#类始终继承自一个基类(如果未在声明中指定一个基类,则继承自System.Object)。 派生类继承基类的语法如下: 1 using System; 2 public class Person 3 { 4 //这是基类 5 } 6 public class Student:Person 7 { 8 //这是派生类 9 } 注:派生类继承基类时用“:”符号连接,派生类继承基类的所有非私有成员变量和方法。 2 、调用基类的构造函数: 如果对类没有定义显式构造函数,则编译器将提供默认的构造函数,以初始化这些类的成员字段。但是,如果显式添加了构造函数,就可以有效控制整个构造过程。 示例: 1 using System; 2 namespace Jicheng 3 { 4 //基类 5 public class Person 6 { 7 public string _name; 8 public uint _age; 9 //基类的构造函数 10 public Person(string name,uint age) 11 { 12 this._name = name; 13 this._age = age; 14

eclipse打开异常(No Java virtual machine was found after searching the following locations)

匿名 (未验证) 提交于 2019-12-02 21:53:52
描述:点击桌面的eclipse快捷方式打开eclipse后出现以下提示框 No Java virtual machine was found after searching the following locations 翻译过来就是:在以下的地址找不到java虚拟机 错误的意思是:在指定的路径D:\eclipse\jre\bin\javaw.exe下面没有找到javaw.exe。原因是Eclipse启动的时候需要javaw.exe来启动,启动Eclipse时,程序会先查询系统变量PATH,若无;则在Eclipse的安装目录(如D:\eclipse\)中查询,若还是没有查询到,则会出现上面的错误提示。 这里采用的解决方法是 配置javaw.exe的环境变量 1)找到你所需的jdk的javaw.exe路径 2)系统环境变量PATH中,添加javaw.exe的路径系统环境变量PATH中,添加javaw.exe的路径 3)这时候能够在eclipse的文件夹目录下点击eclipse.exe来打开eclipse,但想通过建立在桌面上的快捷方式打开还是会出现同样错误 4)要想通过建立在桌面上的快捷方式打开eclipse,直接把jdk的jre文件夹copy到eclipse的目录下 问题解决~ 文章来源: eclipse打开异常(No Java virtual machine was found

JAVA栈溢出

匿名 (未验证) 提交于 2019-12-02 21:52:03
今天偶然有人问起如何在编写Java代码使其在运行时抛出栈溢出异常,看似简单的问题涉及到了Java虚拟机的知识,特记录于此文。 根据《Java虚拟机规范》 (The Java Virtual Machine Specification) 对于Java虚拟机运行时数据区域 (Run-Time Data Areas) 的描述,虚拟机运行时的描述,其构成图如下所示: 图中,PC寄存器、Java虚拟机栈及本地方法栈为各线程私有,方法区(包括运行时常量取)及堆为线程间共享的存储空间。针对问题提出的栈溢出,有两个区域与其相关,包括Java虚拟机栈及本地方法栈。查阅《Java虚拟机规范》,针对栈溢出有如下两段描述: 对于Java虚拟机栈 The following exceptional conditions are associated with Java Virtual Machine stacks: If the computation in a thread requires a larger Java Virtual Machine stack than is permitted, the Java Virtual Machine throws a StackOverflowError . If Java Virtual Machine stacks can be dynamically

How to ensure that virtual method calls get propagated all the way to the base class?

。_饼干妹妹 提交于 2019-12-02 20:40:29
One very common mistake with class hierarchies is to specify a method in a base class as being virtual, in order for all overrides in the inheritance chain to do some work, and forgetting to propagate the call on to base implementations. Example scenario class Container { public: virtual void PrepareForInsertion(ObjectToInsert* pObject) { // Nothing to do here } }; class SpecializedContainer : public Container { protected: virtual void PrepareForInsertion(ObjectToInsert* pObject) { // Set some property of pObject and pass on. Container::PrepareForInsertion(pObject); } }; class

How to calculate page table size?

淺唱寂寞╮ 提交于 2019-12-02 20:39:42
Given : 64 bit virtual byte address, 16 KB pages, 32-bit physical byte address. What is the total size of page table on this machine, assuming that the valid, protection, dirty and use bits take a total of 4 bits and all virtual pages are in use. So far I know the total number of page table entries : 2^64 / 2^14 = 2^50, but am not able to understand how to find the size of each entry. Each entry does contain 4 bits as said in the question, but can the size rest of the entry be found from the physical byte address? I'm confused in this part. Thanks. See below one method of calculating page

How to write a virtual printer driver for Mac OSX [closed]

♀尐吖头ヾ 提交于 2019-12-02 19:34:22
I need to write a "virtual printer driver" for OSX, so that when the user presses Command+P to open the Print dialog, he sees my virtual printer...which will be used to generate files of various types, instead of physically printing to paper. I'm new to the subject, I looked around a bit but found nothing. Do you have any link or reference to documentation that cover this topic? Rather than writing a driver, consider using the PDF Services feature of OS X print dialogs. In either the system-wide /Library/PDF Services or a user's ~/Library/PDF Services directory, you can put AppleScripts,

How to hack the virtual table?

一笑奈何 提交于 2019-12-02 19:30:38
I would like to know how to change the address of Test which is in the virtual table with that of HackedVTable . void HackedVtable() { cout << "Hacked V-Table" << endl; } class Base { public: virtual Test() { cout <<"base"; } virtual Test1() { cout << "Test 1"; } void *prt; Base(){} }; class Derived : public Base { public: Test() { cout <<"derived"; } }; int main() { Base b1; b1.Test(); // how to change this so that `HackedVtable` should be called instead of `Test`? return 0; } Answer will be greatly appreciated. Thanks in advance. This works for 32-bit MSVC builds (it's a very simplified

Mongoose virtual fields included in toJSON by default: schemaOptions.toJSON.virtuals = true; still doesn't include virtual fields by default

旧巷老猫 提交于 2019-12-02 18:52:47
I saw in another answer that in order to include the virtual fields you must do like https://groups.google.com/forum/?fromgroups#!topic/mongoose-orm/HjrPAP_WXYs var schemaOptions = { toJSON: { virtuals: true } }; which I've done; Now in the Schema: new Schema({...}, schemaOptions); But still so, the data doesn't include the virtual.. :s But like this works: var docsCallback = function(err, docs){ var i = docs.length; var nDocs = []; while(i--){ nDocs[i] = docs[i].toObject({virtuals: true}); } done(nDocs); } Just tried: var schemaOptions = { toObject: { virtuals: true } }; and worked! ;) Now by

Is final used for optimization in C++?

我们两清 提交于 2019-12-02 18:46:50
class A { public: virtual void f() = 0; }; class B : public A { public: void f() final override { }; }; int main() { B* b = new B(); b->f(); } In this case, is the compiler required to still do the v-table lookup for b->f(); , or can it call B::f() directly because it was marked final ? Niall Is final used for optimization in C++? It can be, and is. As noted, it is being used already; see here and here showing the generated code for the override with and without final . An optimisation along these lines would relate to the "de-virtualization" of the virtual calls. This is not always

三维点云表示

折月煮酒 提交于 2019-12-02 17:57:44
原文链接 点云数据结构 点云数据结构 非常简单,只有点的三维坐标信息和法线信息。下面是一个点云表示的抽象类: class GPP_EXPORT IPointCloud { public: IPointCloud(){} virtual Int GetPointCount() const = 0; virtual Vector3 GetPointCoord(Int pid) const = 0; virtual void SetPointCoord(Int pid, const Vector3& coord) = 0; virtual Vector3 GetPointNormal(Int pid) const = 0; virtual void SetPointNormal(Int pid, const Vector3& normal) = 0; virtual bool HasNormal() const = 0; virtual void SetHasNormal(bool has) = 0; virtual Int InsertPoint(const Vector3& coord) = 0; virtual Int InsertPoint(const Vector3& coord, const Vector3& normal) = 0; virtual void