answersLogoWhite

0


Best Answer

In order to access a base class member the base class member must be declared protected or public. Private data is only accessible to members of the same class and to friends of the class. I'm not entirely sure what you mean by accessing from a database. A derived class does not require a database in order to access its base class members, it only requires protected access at the very least. Note that although you can declare derived classes to be friends of their base classes and thus allow private access, it would be an unusual design since base classes should never know anything about any of their derivatives.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can the base class data be accessed from database directly using derived class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Math class is an example of which class?

It is a static class; meaning that all the methods can be accessed directly from the class name, without instantiating an object.It is a static class; meaning that all the methods can be accessed directly from the class name, without instantiating an object.It is a static class; meaning that all the methods can be accessed directly from the class name, without instantiating an object.It is a static class; meaning that all the methods can be accessed directly from the class name, without instantiating an object.


If a data-item is declared as a protected access specifier then it can be accessed?

A class method or attribute (data item) that is declared protected can be accessed only by methods of the same class or by methods of derived classes of the class.


How can you access private functions of a class from the Main function in Cpp?

Any member functions and data members declared as 'private' in a class, can only be accessed directly by functions within the class.They cannot be accessed directly by derived objects, nor from anywhere outside an object of the class, such as from the Main function.To access private class members, you must rely on what are called accessor functions. Accessor functions are functions inside the class, either public or protected, which automatically have access to private members.If a function from Main, or elsewhere outside the class hierarchy, needs access, then you need to use publicaccessor functions. For derived class access, you can use protected accessor functions.


Is the default access specifier same as protected?

A private member of a class can only be accessed by methods of that class. A protected member of a class can only be accessed by methods of that class and by methods of a derived class of that class.


What is multilevel inheritance in C plus plus?

Multi-level inheritance involves at least 3 classes, a, b and c, such that a is derived from b, and b is derived from c. c is therefore the least-derived base class, b is an intermediate base class and a is the most-derived class.

Related questions

Math class is an example of which class?

It is a static class; meaning that all the methods can be accessed directly from the class name, without instantiating an object.It is a static class; meaning that all the methods can be accessed directly from the class name, without instantiating an object.It is a static class; meaning that all the methods can be accessed directly from the class name, without instantiating an object.It is a static class; meaning that all the methods can be accessed directly from the class name, without instantiating an object.


If a data-item is declared as a protected access specifier then it can be accessed?

A class method or attribute (data item) that is declared protected can be accessed only by methods of the same class or by methods of derived classes of the class.


How can you access private functions of a class from the Main function in Cpp?

Any member functions and data members declared as 'private' in a class, can only be accessed directly by functions within the class.They cannot be accessed directly by derived objects, nor from anywhere outside an object of the class, such as from the Main function.To access private class members, you must rely on what are called accessor functions. Accessor functions are functions inside the class, either public or protected, which automatically have access to private members.If a function from Main, or elsewhere outside the class hierarchy, needs access, then you need to use publicaccessor functions. For derived class access, you can use protected accessor functions.


Is the default access specifier same as protected?

A private member of a class can only be accessed by methods of that class. A protected member of a class can only be accessed by methods of that class and by methods of a derived class of that class.


Private in java?

The private identifier is used to specify that an element can not be directly accessed from the outside. For example, a field or method declared as private can not be accessed directly from outside of the object or class in which it is used.


What is inheirtance in java?

It is basically the same as inheritance in other languages. A derived class can inherit from a parent class, meaning that the derived class will have the characteristics (variables, and procedures - called fields, and methods, in this case) of the parent class. It may also have additional characteristics, defined directly in the derived class.


What is multilevel inheritance in C plus plus?

Multi-level inheritance involves at least 3 classes, a, b and c, such that a is derived from b, and b is derived from c. c is therefore the least-derived base class, b is an intermediate base class and a is the most-derived class.


What is private specifier in c plus plus?

The private specifier states that the member can only be accessed by the containing class, and not by any derived class, nor by any other code outside of a class.


How do you achieve encapsulation by using class?

By making fields private. That way, they can't be directly accessed from the outside - the are hidden, that is, encapsulated.


What is the application of public protected and private keywords?

The public, protected, and private keywords are access modifiers that specify if the item they modify can be accessed inside or outside the class or a derived class.A public item is fully accessible, inside or outside the class, including inside a derived class.A protected item is accessible only inside the class or inside a derived class.A private item is accessible only inside the class.


What is single inheritance in c plus plus?

Multiple inheritance occurs when a class is derived directly from two or more base classes. class b1 {}; class b2 {}; class d: public b1, public b2 {}; // multiple inheritance class


Difference between base class and derived class?

The derived class derives, or inherits, from the base class. The derived class is like a "child", and the base class, the "parent". The child class has the attributes of the parent class - its variables (those defined at the class level) and methods. Changes done to the parent class (the base class) will affect the child class (the derived class).