Highlighted
Super Contributor.
Super Contributor.
1090 views

Does Visual COBOL support Constructor Initializers ?

Jump to solution

This is code from a C# program:

using DevExpress.Xpo;

public class Customer : XPObject {
    public Customer() {}
    public Customer(Session session) :
            base(session) {
    }
XPObject and Session are DevExpress classes used for data binding.

In C#, a constructor initializer is the code that comes after a colon in a method definition.

My understanding is that ": base(session)" in the overloaded constructor will execute the overloaded constructor in the inherited class XPObject passing it the "session" parameter.  How would you code the above in Visual COBOL ?  I can't find documentation on it.  When DevExpress calls the Customer(Session) constructor, the constructor execution sequence should be:

- System.Object.Object

- XPObject (Session)

- Customer(Session)  which in my COBOL program would be NEW(Session).

Phil Levin

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Does Visual COBOL support Constructor Initializers ?

Jump to solution

Hi Phil, should be something like:

method-id new.

procedure division using by value session as type Session.

   invoke super::new(session)

   ....

end method.

View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Does Visual COBOL support Constructor Initializers ?

Jump to solution

Hi Phil, should be something like:

method-id new.

procedure division using by value session as type Session.

   invoke super::new(session)

   ....

end method.

View solution in original post

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Does Visual COBOL support Constructor Initializers ?

Jump to solution

Thanks Robert.  That compiled.  Now I can use a bunch of DevExpress data binding tools.

Phil Levin

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.