answersLogoWhite

0

A pure-virtual method is similar to a virtual method. A virtual method is a method that is expected to be overridden in a derived class while a pure-virtual method must be overridden in a derived class. The base class may provide a default implementation for a pure-virtual method, but it is not a requirement, whereas it must provide an implementation for a virtual method. In addition,

any base class that has a pure-virtual method becomes abstract; you cannot instantiate abstract classes -- you are expectedto derive from them.

#include

class Abstract

{

public:

// Pure-virtual method; note the '=0' to denote pure-virtual.

virtual void Show()=0;

};

class Derived : public Abstract

{

public:

virtual void Show()

{

// Implementation is required here!

std:: cout << "Derived" << std::end;

}

};

void main()

{

// Abstract a; // Compiler error!

Derived d;

d.Show(); // Call pure-virtual method.

return( 0 );

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is meant by extension?

extensible means to enhance the program with new capabilities. In c++, extensibility can be achieved by using virtual function. now first we discuss what is virtual function in c++. " C++ virtual function is a member function of a class, whose functionality can be over-ridden in its derived classes. The whole function body can be replaced with a new set of implementation in the derived class." Through this u can be able to promote extensibility in your program by using Virtual function. Very simple concept.


Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


Write a c program for matrix addition using function?

#include&lt;


Write a program to calculate the area of a cylinder using a function?

give an example of calculation of mathematics


Write a Program to convert decimal number into hexadecimal no without using function and string?

This is not a question.


Can you write a program without using any semicolon inside the main function?

not possible dude


How do you write a c program to find area of rectangle using function?

There will be a function in it like this: double RectangleArea (double a, double b) { return a*b; }


How do you write a program using function that counts the number of vowels in a string in java language?

Use text-editor notepad++


Write a program to swap two numbers using function?

swap (int *a, int *b) { *a ^= *b; *b ^= *a; *a ^= *b; }


How do you write a programm in c plus plus without using function main?

I don't think its possible. Every C++ program must at least have the main function.


How do you write a program using the gotoxy statement and print function to display letters of the alphabet on the computer screen?

There is no gotoxy statement in C.


Write a sample program using ASPNET explaining all the syntax and semantics of the program?

write a sample program using asp.net explaining all the syntax and semantics of the program