Intro to OO Programming for COBOL Developers

Working through the above titled PDF I get a build error with the following line of code:

set an-obj to MyClass::New("Scot")

The error I get is 

Severity

Code

Description

Project

File

Line

Error

COBCH0012 : Operand MyClass is not declared

OOSample

C:\Users\mike\Documents\Visual Studio 2015\OOSample\OOSample\TestMyClass.cbl

7

TestMyClass.cbl looks like:

       program-id. TestMyClass as "OOSample.TestMyClass".

       

       01  an-obj type MyClass.

       procedure division.

     *     set an-obj to new MyClass("Scot")

           set an-obj to  MyClass::New("Scot")

           invoke an-obj::SayHello.

           

       end program TestMyClass.

When I comment out the second "set" statement and uncomment the first, then it works fine.

I am using Visual Cobol Personal Edition 2.3 on Visual Studio 2015 on Windows 10.

Tags:

  • Verified Answer

    This appears to be a bug in the PDF file.

    The second instantiation should contain the keyword type in front of MyClass as MyClass is a class name and not an object itself.

       set an-obj to type MyClass::New("Scot")

    I will report this as a bug but I would recommend that you always use the syntax specified in the first form of the statement as this is the newer and simpler version of the syntax.

    Thanks.

  • Thank you Chris.  

    Being new to OO Cobol I wasn't sure if maybe something had changed between when the PDF came out and Visual Cobol 2.3.

    Also, are there any compiler directives to use the ISO standard for OO Cobol since I'm assuming any other OO Cobol tutorials I find will use the ISO version.