#include <stdio.h>

/**
*** This is our cobol function definition.
**/
extern "C" void cobfunc1(int * x, float * y, char * z);
extern "C" int cobtidy(void);  

class Ctest
{
private:
    int   a;
    float b;
    char  c;

public:
    Ctest();
    Ctest(int x, float y, char z);

    void  set_a(int x);
    void  set_b(float x);
    void  set_c(char x);
    int   get_a();
    float get_b();
    char  get_c();
    void  func1();
};


Ctest::Ctest()
{
    a = 0;
    b = 0;
    c = ' ';
}

Ctest::Ctest(int x, float y, char z)
{
    a = x;
    b = y;
    c = z;
}

void Ctest::set_a(int x)
{
    a = x;
}

void Ctest::set_b(float x)
{
    b = x;
}
void Ctest::set_c(char x)
{
    c = x;
}

int  Ctest::get_a()
{
    return(a);
}

float Ctest::get_b()
{
    return(b);
}

char Ctest::get_c()
{
    return(c);
}

void Ctest::func1()
{
    /**
    *** This is the call to the Cobol function
    **/
    cobfunc1(&a, &b, &c);
}


int main()
{
    Ctest Ctestdata1;
    Ctest *Ctestdata2 = new Ctest(100, 100.5, 'a');

    printf("Starting C++ cxxmain \n");

    /**
    *** Here we are calling Cobol...
    **/
    Ctestdata1.func1();

    printf("Returned to cxxmain\n");

    if(Ctestdata1.get_a() == Ctestdata2->get_a())
	printf("Int C++ test passed\n");
    else
	printf("Int C++ test failed\n");

    if(Ctestdata1.get_b() == Ctestdata2->get_b())
	printf("Float C++ test passed\n");
    else
	printf("Float C++ test failed\n");

    if(Ctestdata1.get_c() == Ctestdata2->get_c())
	printf("Char C++ test passed\n");
    else
	printf("Char C++ test failed\n");

    /**
    *** Now we just need to deinitialise the Cobol system.
    **/
    cobtidy();

    return 0;
}
