virtual

Why do I need to redeclare overloaded virtual functions?

自作多情 提交于 2020-11-29 09:34:08
问题 I have a base class with two overloaded functions f(void) and f(int) . The class Derived implements f(int) by calling f(void) . Derived2 implements f(void) only. The compiler rejects the implementation Derived::f(int) because it wants to call f(int) but I provided no arguments because I want to call f(void) . Why does the compiler reject it? Why does adding the line virtual int f(void) = 0; fix my problem? class Base { public: explicit Base(void) {} virtual ~Base(void) {} virtual int f(void)

Where do I find the assembly that creates a static variable in the .data section of my C program?

删除回忆录丶 提交于 2020-11-28 01:41:44
问题 First time poster. 2nd year CS student. I am exploring the creation of static variables in the .data section of the Virtual Address Space in the context of a C source->GCC compilation->Linux execution environment. C program is test.c int main() { register int i = 0; register int sum = 0; static int staticVar[10] = {1,2,3,4,5,6,7,8,9,-1}; Loop: sum = sum + staticVar[i]; //optimized away i = i+1; if(i != 10) goto Loop; return 0; } Asking GDB to ' disass /m ' reveals that there is no code for

Why the Items of a Virtual ListView that are not visible don't have index?

二次信任 提交于 2020-08-09 09:53:06
问题 I'm working with a ListView in Virtual Mode (.NET 4.6). I tried to find the index of Items in the virtual ListView: when I enter a letter, the first item with text that start with that letter should be selected. Here is the FindItemWithText in listView1_KeyDown : if (char.IsLetterOrDigit(e.KeyChar)) { var str = e.KeyChar.ToString(); if (tempStr != str) { Index = 0; tempStr = str; } var item = listView1.FindItemWithText(str, false, Index, true); if (item != null) { item.Selected = true; item

c++ : code explanation for method prototype with const = 0

有些话、适合烂在心里 提交于 2020-07-15 01:00:10
问题 I hava a class declaration with a piece of code that I do not understand : class Weapon { public: virtual void attack() const = 0; }; What does the const = 0 part means ? 回答1: This is a pure virtual method ( =0 ) which is not supposed to change the data of the class ( const ). You should provide an implementation in one of the classes deriving from Weapon ! See this: Difference between a virtual function and a pure virtual function You are expected to derive from the Weapon (can be considered

c++ : code explanation for method prototype with const = 0

笑着哭i 提交于 2020-07-15 01:00:06
问题 I hava a class declaration with a piece of code that I do not understand : class Weapon { public: virtual void attack() const = 0; }; What does the const = 0 part means ? 回答1: This is a pure virtual method ( =0 ) which is not supposed to change the data of the class ( const ). You should provide an implementation in one of the classes deriving from Weapon ! See this: Difference between a virtual function and a pure virtual function You are expected to derive from the Weapon (can be considered

why OS create the virtual memory for running process

这一生的挚爱 提交于 2020-06-29 03:48:14
问题 when a program started the OS will create a virtual memory , which divided into stack , heap , data , text to run a process on it.I know that each segment is used for specification purpose such as text saves the binary code of program, data saves static and global variable. My question is why the OS need to create the virtual memory and divide it into the segments ? How about if OS just use the physical memory and the process run directly on the physical memory. I think maybe the answer is