answersLogoWhite

0


Best Answer

An abstract class is any class definition that contains at least one pure-virtual function.

class AbstractClass

{

public:

virtual void DoSomething()=0; // Pure-virtual.

};

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write abstract class in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Is an abstract class virtual by default?

Unlike abstract class in C++, the abstract class in C# does not have any methods defined as virtual by default. The concept of virtual are not the same between C# and C++, either. Any virtual method must be defined explicitly in C#. Related to abstract methods - interestingly, an abstract class in C# does not have to have any abstract methods. However, the reverse, if a class need to have at least one abstract method, that class must be defined as abstract.


Is an abstract class cannot have any member variable in C plus plus?

An abstract base class may have member variables. Whether or not it actually needs member variables depends on the nature of the base class itself. If the variable is common to all derived classes, then it makes sense to place the variable in the base class. If some derived classes have no need of the variable, then it is better to derive an intermediate class with the variable, and to derive those classes that require that variable from the intermediate class, rather than directly from the abstract class.


What is a Concrete class in c plus plus?

A concrete class is a complete type, as opposed to an abstract class which is an incomplete type.class A {public:virtual void f () = 0; // pure-virtual; class A is abstract// ...};class B : public A {public:void f () override; // overrides A::f(); class B is concrete};class C {// no pure-virtual methods; C is a concrete type// ...};Template classes are generic types. We usually evolve a generic type from a concrete type rather than write a template class from scratch, a technique known as lifting. The concrete type provides us with the complete implementation which is useful for testing and debugging purposes. When the concrete class is fully-implemented and error-free, we can generalise to produce the generic type.


How do you write classes and objects for hospital management software using objective c or c plus plus?

You declare a class as follows: class MyClass { //some stuff here... } You create an object as follows: MyClass object; This is how you create classes and objects in C++.


What is abrstac class and virctul function in c?

I have to assume the question is for C#, not C, because C does not provide abstract class concept.public abstract class A1 { public virtual void SayHi() { Console.WriteLine("Hello World"); }public abstract void DoSomething();}The above abstract class A1 contains 1 virtual method and 1 abstract method. [Note that because of the abstract keyword for Dosomething(), A1 must be declared as abstract. An abstract class DOES NOT have to have any abstract methods!!)The virtual function SayHi() provides a implementation, while the abstract function provides nothing but only the method signature( the name of the method, the return type, and method parameters and their data types). The derived class of A1 has the option to override SayHi() and must implement (or defer to subclasses of this derived class) the method DoSomething()

Related questions

What are the abstract datatypes in c plus plus?

Class Object Message


Is an abstract class virtual by default?

Unlike abstract class in C++, the abstract class in C# does not have any methods defined as virtual by default. The concept of virtual are not the same between C# and C++, either. Any virtual method must be defined explicitly in C#. Related to abstract methods - interestingly, an abstract class in C# does not have to have any abstract methods. However, the reverse, if a class need to have at least one abstract method, that class must be defined as abstract.


When you define a c plus plus class what items are considered part of the interface?

The interface of a C++ class is the public methods and attributes that are exposed by the class. In a pure abstract base class, the interface is enforced by the compiler in each of the derived child classes.


Is an abstract class cannot have any member variable in C plus plus?

An abstract base class may have member variables. Whether or not it actually needs member variables depends on the nature of the base class itself. If the variable is common to all derived classes, then it makes sense to place the variable in the base class. If some derived classes have no need of the variable, then it is better to derive an intermediate class with the variable, and to derive those classes that require that variable from the intermediate class, rather than directly from the abstract class.


Write a c plus plus programme to illustrate single inheritance?

struct A {}; // base class struct B : A {} // derived class (single inheritance).


What is a Concrete class in c plus plus?

A concrete class is a complete type, as opposed to an abstract class which is an incomplete type.class A {public:virtual void f () = 0; // pure-virtual; class A is abstract// ...};class B : public A {public:void f () override; // overrides A::f(); class B is concrete};class C {// no pure-virtual methods; C is a concrete type// ...};Template classes are generic types. We usually evolve a generic type from a concrete type rather than write a template class from scratch, a technique known as lifting. The concrete type provides us with the complete implementation which is useful for testing and debugging purposes. When the concrete class is fully-implemented and error-free, we can generalise to produce the generic type.


Can a c plus plus class be derived from a Java class?

No.


How do you write classes and objects for hospital management software using objective c or c plus plus?

You declare a class as follows: class MyClass { //some stuff here... } You create an object as follows: MyClass object; This is how you create classes and objects in C++.


What is abrstac class and virctul function in c?

I have to assume the question is for C#, not C, because C does not provide abstract class concept.public abstract class A1 { public virtual void SayHi() { Console.WriteLine("Hello World"); }public abstract void DoSomething();}The above abstract class A1 contains 1 virtual method and 1 abstract method. [Note that because of the abstract keyword for Dosomething(), A1 must be declared as abstract. An abstract class DOES NOT have to have any abstract methods!!)The virtual function SayHi() provides a implementation, while the abstract function provides nothing but only the method signature( the name of the method, the return type, and method parameters and their data types). The derived class of A1 has the option to override SayHi() and must implement (or defer to subclasses of this derived class) the method DoSomething()


Is reader class is an abstract class?

For Java: Yes, Reader is an abstract class in package of java.io; For C#: No, Reader is NOT one of the defined library classes. Of course you create one.


What is the role of object in c plus plus?

An object in C++ is an instance of a C++ class.


What is abrstac class and virctulfunction in c sharp?

abstract class is a class label with abstract. It is just like a common class, with the following characterics: 1. Abstract class cannot be instantiate with an instance. 2. Abstract class may have abstract methods, while the normal class cannot have abstract methods. a virtual function in C# is a way to provide a default implementation for the class hierarchy. Both abstract class and common class (not sealed) can have virtual methods/ functions. Note that an abstract method (of an abstract class) is defining the intent, no codes (no default behavior), the implementation are left for the derived classes to do so. The virtual function if defined in an abstract class must define the implementation, the minimum is to do nothing: public abstract class Vehicle { public abstract int GetNumberOfTires(); public virtual void Move() { // default is doing nothing} } public class Car : Vehicle { public override int GetNumberOfTires() { return 4; } public override void Move() { throws new OutOfFuelExpection(); } }