Главная страница | назад





Article #16384: C++ and Pascal

 Question and Answer Database
FAQ1384C.txt C++ and Pascal
Category :C/C++ Language Issues
Platform :All
Product :C++Builder 1.x
Question:
I am C++ programmer and not familiar with pascal. Can you
give me a few pointers that will help?
Answer:
Here are some pointers:
 — Function ( procedure ) calls don't require parenthesis.
 — When you see '.' in pascal, you probably need the '->'
in C/C++.
Form2.Show; (* Opascal *)
Form2->Show(); // C++
 — Don't forget assignment operator is a colon equals
combination ':='.
 — Create and CreateNew are Object Pascal's constructors.
 — The inherited statement is used to tell the compiler
not to call the function named in the current class,
but to use the one in the next class higher in the
hierarchy. If not, there continue searching up the
hierarchy. This is the same as the super keyword in
Java or Smalltalk.
 — Bar = class(Foo) in Opascal says a variable of
type class Bar inheirits compatibliliy with class Foo.
type
Shape = class
. . .
end;
Rectangle = class(Shape)
. . .
end;
Square = class(Rectangle)
. . .
end;
Circle = class(Shape)
. . .
end;
In example above a value of Rectangle can be assigned to
variables of type Rectangle, Shape, or TObject ( base of all
VCL classes.) At runtime a variable of type Shape can reference
an instance of Shape, Rectangle, Square, or Circle or any other
instance or a class derived from Shape.
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99