Question
Consider the following C++ code: #include class Base { public: Â Â virtual void show() = 0; }; class Derived : public Base { public: Â Â void show() override { Â Â Â Â std::cout
Solution
o In C++, Base is declared with virtual void show() = 0;, which makes show() a pure virtual function. o Any class that contains one or more pure virtual functions is an abstract class. o Abstract classes cannot be instantiated directly. Attempting to create an object of an abstract class (like Base b;) will result in a compile-time error. The compiler will typically issue a message similar to "cannot declare variable 'b' to be of abstract type 'Base'" or "cannot instantiate abstract class 'Base'".
- What is the time complexity of the KMP algorithm for searching a pattern of length 'M' in a text of length 'N'?
- Which of the following scheduling algorithms minimizes average seek time?
- In a digital communication system, let the encoding scheme be “Add 1 at the end of the bit stream if number of 1 bits is odd, else add 0 at the end of bit ...
- float i=10; int f=i; What kind of typecasting is happening in the above scenario a ?
- What mechanism is primarily responsible for managing the sequence of function calls and their local variables in a recursive function?
- Which of the following statement is TRUE related to Alpha Beta pruning algorithm?
- The following Java code attempts to demonstrate multiple inheritance, which is not directly supported for classes in Java. How can similar functionality be...
- Which of the following operation is performed by Domain Name Server (DNS)?
- In Operating Systems, what is 'thrashing'?
- What is the primary objective of the Producer-Consumer problem in concurrent programming?