Highlighted
Absent Member.
Absent Member.
981 views

abstract method

Jump to solution

I have a class that inherits from an abstract class.  Inside of this class is an abstract method.  In the inherited class I want the abstract method to be private.  When I code override I get an error that says "COBCH0965: Overriding method must have visibility Public" and from my understanding of Visual Cobol is legitimate.  The question comes into play when I use the cobol keyword override it seems to build just fine.  Is this the intent?  Below is an example of the redefines code.      

class-id Ufg.Life.Policy.PolicyAbstract abstract.

method-id GetPlanCode abstract

procedure division returning returningPlanCode as String.

end method.

*************** now for the class that inherits from the above class

class-id Ufg.Life.Policy.InforcePolicy inherits type Ufg.Life.Policy.PolicyAbstract.

method-id GetPlanCode redefine private

procedure division returning returningPlanCode as String.

end method.

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: abstract method

Jump to solution

Can you please clarify your question as you mention an error using override yet the example you show is using redfine and not override.

The redefine should work OK as this simply hides the method implementation in the parent class and redefines it using the new definition.

Using override is different and the rules state that if you use override then the method must be defined as public and hence the error that you are seeing.

Thanks.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: abstract method

Jump to solution

Can you please clarify your question as you mention an error using override yet the example you show is using redfine and not override.

The redefine should work OK as this simply hides the method implementation in the parent class and redefines it using the new definition.

Using override is different and the rules state that if you use override then the method must be defined as public and hence the error that you are seeing.

Thanks.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.