F
F
freecam2020-11-21 20:33:41
C++ / C#
freecam, 2020-11-21 20:33:41

How to represent struct in pascal?

How to represent such a structure in Pascal:

struct Name
{
  string String; 
  bool Log; 
  Name(const string& str ="", bool b = false)
    : String(str), Log(b) {}
}
?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2020-11-21
@galaxy

There are no classes in pure Pascal, so a structure with methods (in particular, with a constructor) cannot be made.
An analogue of C-structures in Pascal is the composite type record:

type TName = Record
       Str: String[20];
       Log: Boolean
     end

If you want analogues of C++ classes - take Object Pascal, for example, as part of Delphi or Lazarus

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question