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
• 2,460 points
20 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
• 3,780 points

Related Questions In C++

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
• 3,780 points
20 views
0 votes
1 answer

Easiest way to convert int to string in C++

C++ adds std::stoi (and variants for each numeric type) and std::to string, which are the C equivalents of atoi and itoa but expressed in terms of std::string #include <string> std::string s = std::to_string(42); Is therefore ...READ MORE

answered Jun 1 in C++ by Damon
• 3,780 points
25 views
0 votes
1 answer

How to use std::sort to sort an array in C++

We receive std::begin and std::end in C++0x/11, which are overloaded for arrays: #include <algorithm> int main(){ int v[2000]; ...READ MORE

answered Jun 1 in C++ by Damon
• 3,780 points
15 views
0 votes
1 answer

Using getline() in C++

If you use getline() after cin >> anything, you must first flush the newline character from the buffer.  You can achieve this by using the cin.ignore() It would be something like this: string messageVar; cout ...READ MORE

answered Jun 1 in C++ by Damon
• 3,780 points
17 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
190 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,373 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
787 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
585 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
• 3,780 points
11 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
• 3,780 points
13 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