Slimelite BBS

Pascal to c++; marilyn ma

Back to EMULATE

From Jerry Jankura · 1996-03-30 22:35 · #73504 in EMULATE

CC>i am new to c++ and used to pascal..i am just wondering if anybodycan tell me
CC>the c++ equivilents to the following pascal procs/funcs/whatever:

Assuming that you are using Borland's C++ compiler, here are some
equivalents to what you're asking. If you use a different vendor's
compiler, you might find that some of what I've written must be
modified.

CC>  ptr()        (p:=ptr($a000,$0320); {p=pointer})
     p = MK_FP(0xA000,0x0320);

CC>  new()        (new(p);)
     p = new whateveritis;

CC>  dispose()    (dispose(p);)
     delete p;

CC>  getmem()     (getmem(p,1);)
CC>  freemem()    (freemem(p,1);)

CC>  absolute     (var b : byte absolute $b800:0080;)
     unsigned char *b;
     b = MK_FP(0xB800, 0x0080);
     Refer to the variable as *b, as in the example:

     unsigned char a;
     a = *b;
     *b = 'D';

CC>  pointer      (var p : pointer; {think this is same as "void *p;")

     You got that one right

CC>  boolean      (is there one?)

     The newest draft specification for C++ provides a bool data type
     which acts like Pascal's boolean; However, most of the compilers
     haven't caught up yet. I think that Borland's (5.0) has, but I have
     yet to try it.

CC>  pchar        (think this is same as "char *x;")
CC>  ^variable    (is this the same as "<type> *<var>"?)

     Those look OK too. You also have a reference data type that is
     about the same as Pascal's "var" parameter. If you wrote the
     following in Pascal:

     function funcname(var Parameter : Integer) : Real;

     you would translate into C++ as:

     double funcname(int &Parameter);

CC>also, how do i link .obj files into c++ proggys..and finally..how would i go
CC>about making a .tpu equivilent in c++?..(.lib's?..if so..how?)..

If you're just starting out, you probably should use the integrated
environment that comes with your compiler. You would create a "project"
that would specify all of the files necessary and then direct the IDE
(another term for the integrated environment) to build your system into
an executable. I'd suggest reading through the examples that came with
your compiler for that one. From what I know about Pascal, the C++
object file (.obj) is about equivalent to Pascal's TPU. The library file
(.lib) is a group of object files stuck together as one file. I'm
currently writing some code in Borland's Delphi, and it also provides a
library of units, which is similar to what the C++ library file is. Hope
this provides you with a decent start!
---
 * OLX 2.1 TD * The 4 food groups: Fast, Frozen, Instant, & Microwaved


--- InterEcho 1.14
 * Origin: PC-Ohio PCBoard * Cleveland, OH * 216-381-3320 (1:157/200)