answersLogoWhite

0


Best Answer

If a class is intended to be used purely as a base class then it must have one or more pure-virtual functions (a function that may or may not have an implementation). Such a class is regarded as being an abstract base class because no instances of the class can be instantiated other than through derivation, and the derivative must provide an implementation or it too becomes an abstract base class. The abstract base class need not declare a pure-virtual method if it inherits one or more pure-virtual methods from another base class but does not provide a complete implementation. Only classes that provide a complete implementation can actually be instantiated. Implementations may be inherited from lower base classes other than the one that declared the function pure-virtual in the first place. Once a derivative implements a pure-virtual function, that implementation may be inherited by subsequent derivatives.

If the base class may be instantiated in its own right then it must not declare any pure-virtual methods, nor must it inherit any pure-virtual methods that have no implementations. In this case the base class may be derived from, but doesn't have to be derived from, whereas an abstract base class must be derived from.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What should be structure of class when it has to be a base for other classes?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a super class in terms of object oriented programming?

A superclass, also referred to as a parent class, is a class what which other classes are derived from. These derived classes are known as either subclasses or child classes.


What other classes can mages turn into on dragonfable?

You can turn into any of the other class (bar the other base classes, and base class Dragon versions)


What is the difference between structure and class with example?

Structures are public by default whereas classes are private by default. Other than that they are exactly the same. struct s { int num; // s.num is accessible outside of the structure }; class c { int num; // c.num is only accessible to the class itself. };


What is hierarchal inheritance?

Hierarchical inheritance is a type of inheritance in object-oriented programming where classes are organized in a hierarchical structure. It means that a derived class can inherit attributes and methods from a base or parent class, and it can further be inherited by other classes. This allows for code reuse and promotes modularity in the program.


When do you use inner classes?

You use inner classes when you know you'll never need to access that class from anywhere else. A common use of this is in a linked list implementation: public class LinkedList { private class LinkedListNode { } } There's no reason for any other class to have access to your node class, so it should be an inner class.


How many failed classes to get held back?

All of them; try not to.


Which class includes all the others?

The superclass or parent class includes all the other classes. All other classes inherit properties and methods from the superclass.


Final classes in java?

A class declared as final means that no other class can inherit from it.


What is the meaning of 'back-to-back classes'?

It means you have one class straight after the other.


What is the schema master?

schema Master All databases have a schema which is a formal definition (set of rules) which govern the database structure and types of objects and attributes which can be contained in the database. The schema contains a list of all classes and attributes in the forest. The schema keeps track of: * Classes * Class attributes * Class relationships such as subclasses (Child classes that inherit attributes from the super class) and super classes (Parent classes). * Object relationships such as what objects are contained by other objects or what objects contain other objects. There is a class Schema object for each class in the Active Directory database. For each object attribute in the database, there is an attributeSchema object. Schem Master is A FSMO role held by single DC in forest


What is difference between structure and class?

The struct default access type is public. A struct shouldtypically be used for grouping data.The class default access type is private, and the default mode for inheritance is private. A class should be used for grouping data and methods that operate on that data.In short, the convention is to use struct when the purpose is to group data, and use classes when we require data abstraction and, perhaps inheritance.In C++ structures and classes are passed by value, unless explicitly de-referenced. In other languages classes and structures may have distinct semantics - ie. objects (instances of classes) may be passed by reference and structures may be passed by value.Technically there are only two differences between classes and structures:classes are declared using the keyword class while structures are declared using the keyword structstructures are entirely public, while classes are private by defaultMost C++ programmers use structures exclusively for data that doesn't require strict validation while classes are used to encapsulate data and the functions that work exclusively with that data. Although classes and structures can largely achieve the same goals, the lack of encapsulation and data-hiding in a structure make it far less robust than a well-designed class would be, with little or no difference in terms of memory consumption. Encapsulation comes into its own when classes become highly-complex (classes within classes) as each class is responsible only for its own data, not the classes it contains. Structures can be just as complex, but because they don't have the safeguards that can built into classes, it only takes one errant function to unwittingly invalidate data. A well-designed class ensures data validity at all times.


What are wrapped classes?

Wrapped classes are wrapped by Visible ones, which means wrapped ones should be invisible. Adapter Pattern is very closely related to wrapper, because it comes with 2 different flavors: object wrapper and class wrapper. There is also another way to define "wrapped" classes: a private class defined within another class. For example: class TheWrapper { private BeingWrapped _internal; } class TheVisibleOne { private class WrappedClass { } // this class is only accessible in TheVisibleOne } BeingWrapped and WrappedClass are the ones being wrapped/hide by other classes.