Declare abstract class in c

0 votes

What is the best way to declare an abstract class?

For instance, I'm aware that it employs the term "virtual," as in:

class test{
public:
virtual void test()=0;
}

My question is can I abstract test class like this? If not why and how

virtual class test{
}

May 28 in C++ by Nicholas
• 5,020 points
31 views

1 answer to this question.

0 votes

An abstract class is one that is intended to be used as a base class . 

At least one pure virtual function exists in an abstract class. 

A pure virtual function is declared in the class declaration by using a pure specifier (= 0) in the declaration of a virtual member function.

Here is an example of an abstract class:

class AB { public: virtual void f() = 0; };

The AB::f function is a pure virtual function. 

There can't be a pure specifier and a definition in the same function declaration. 

The compiler, for example, will not permit the following:

struct A { virtual void g() { } = 0; };
answered May 31 by Damon
• 4,960 points

Related Questions In C++

0 votes
0 answers

What type of members can I add in a c++ abstract class

Hello, let's say I have an abstract class with a few pure abstract functions and a few classes that derive from it, and all of the data from these classes eventually becomes similar, I was wondering if it would be wise, or even possible, to declare a vector under protected in the abstract class to collect the data so something like that. class A { protected: vector <string> ...READ MORE

Jul 27 in C++ by Nicholas
• 5,020 points
8 views
0 votes
0 answers

How do I declare a 2d array in C++ using new?

How do I declare a two-dimensional array using new? For example, for a "typical" array, I would:      int* ary = new int[Size] but int** ...READ MORE

Jul 15 in C++ by Nicholas
• 5,020 points
21 views
0 votes
0 answers

How to declare an array of strings in C++?

I am trying to iterate over all ...READ MORE

Jul 26 in C++ by Nicholas
• 5,020 points
10 views
0 votes
1 answer

What data structure is inside std::map in C++?

An associative container is std::map. The standard's ...READ MORE

answered May 31 in C++ by Damon
• 4,960 points
36 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 11, 2018 in Python by Priyaj
• 58,080 points
206 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 21, 2018 in Python by Priyaj
• 58,080 points
1,414 views
0 votes
1 answer

How to pass large records to map/reduce tasks?

Hadoop is not designed for records about ...READ MORE

answered Sep 25, 2018 in Big Data Hadoop by Frankie
• 9,830 points
808 views
0 votes
1 answer

Invalid method parameters for eth_sendTransaction

params needs to be an array, try {"jsonrpc":"2.0","method":"eth_se ...READ MORE

answered Sep 28, 2018 in Blockchain by digger
• 26,720 points
636 views
0 votes
1 answer

In C++, what is a virtual base class?

When employing multiple inheritance, virtual base classes are used to prevent several "instances" of a particular class from appearing in an inheritance hierarchy. Consider the following example: class A { public: void Foo() {} ...READ MORE

answered Jun 10 in C++ by Damon
• 4,960 points
24 views
0 votes
1 answer

What is a Class and Object in C++?

A Class is like a blueprint, an ...READ MORE

answered Jun 21 in C++ by Damon
• 4,960 points
21 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP