answersLogoWhite

0

Using base in a derived class invokes the base class's corresponding method.

For example, something like:

class Shape{

public void print(){printf("Generic shape");

...

}

class Triangle:Shape{

public void print(){printf("Triangle");

...

}

int main()

{

Triangle x;

x.print(); // Should print "Triangle"

x.base.print(); // Should print "Generic shape"

return 0;

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

What is the use of keyword new used in AWT programming?

what is the use of new keyword in awt programming


What does the keyword extends mean in BlueJ?

The "extends" keyword in Java is how you declare a subclass.class Base {void foo() {}}class Sub extends Base { //Sub is now a subclass of Basevoid begin(){Sub s = new Base(); //cannot do this the other way around!}}


What are the 6 ways to use this keyword?

"Java This keyword" is a reference to the current object, it is very helpful when you need to refer an instance of a particular Object from its available methods or using it's constructor, also "this" keyword helps us to avoid naming conflicts.The following are different ways to use java this keyword1) Using with instance variable2) Using with Constructor3) Pass / Return current instanceUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with ConstructorUsing this keyword inside constructor like followingthis("Sony", 20); it will call the constructor having same parameter


Is super keyword is analogous to this keyword in java?

No. The keyword super is used to refer to the parent class instance while the keyword this is used to refer to the current class instance. You need to learn about Inheritance and Object creation using constructors to learn more about these keywords and their use


What keyword is used to find derivative in C plus plus?

The lazy way is to use a dynamic cast. The correct way is to use virtual functions in the base class. That way you don't ever need to know the derived type -- it simply does what is expected of it.

Related Questions

What happens when the keyword reacts with water to form a strong base?

When the keyword reacts with water, it forms a strong base.


Can I use your keyword in my question?

Yes, you can use the keyword in your question.


Is it okay to use the keyword in this context?

Yes, it is appropriate to use the keyword in this context.


What is the use of keyword new used in AWT programming?

what is the use of new keyword in awt programming


Which keyword do you use to deallocate memory that has been assigned to a stream object?

Delete keyword


Can I use the keyword in an argumentative essay?

Yes, you can use the keyword in an argumentative essay as long as it is relevant to the topic and supports your argument effectively.


What are the two properties of the keyword?

The two properties of a keyword are its relevance to the topic and its frequency of use in a text.


Can you declears static in a local variable in a method in java?

we cannot use the staic keyword inside the method... But we can use the final keyword inside the method....


Can I use the keyword "technology" in my essay about the impact of modern technology on society?

Yes, you can use the keyword "technology" in your essay about the impact of modern technology on society.


What is the significance of the keyword "kb of lioh" in the context of chemistry?

In chemistry, the keyword "kb of lioh" refers to the base dissociation constant of lithium hydroxide. This value is important because it indicates the strength of the base in a solution and helps determine its pH level.


What does the keyword extends mean in BlueJ?

The "extends" keyword in Java is how you declare a subclass.class Base {void foo() {}}class Sub extends Base { //Sub is now a subclass of Basevoid begin(){Sub s = new Base(); //cannot do this the other way around!}}


What are the 6 ways to use this keyword?

"Java This keyword" is a reference to the current object, it is very helpful when you need to refer an instance of a particular Object from its available methods or using it's constructor, also "this" keyword helps us to avoid naming conflicts.The following are different ways to use java this keyword1) Using with instance variable2) Using with Constructor3) Pass / Return current instanceUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with ConstructorUsing this keyword inside constructor like followingthis("Sony", 20); it will call the constructor having same parameter