Thread: Pascal "with()" in C++

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User larry's Avatar
    Join Date
    Sep 2001
    Posts
    96

    Pascal "with()" in C++

    Is there something like Pascal "with" keyword in C++?
    I used it in Pascal this way:

    type Tstructure = record {equals to typedef struct in C++}
    element1: boolean;
    element2: integer; {and so on}
    end;

    var structure: Tstructure;

    procedure viewelements(); {prints contents of the two elements}
    begin
    if structure.element1 then writeln('true') else writeln('false');
    writeln(inttostr(structure.element2));
    end;

    procedure viewelementsUsingWith(); {prints contents of the two elements using with keyword}
    begin
    with structure do begin
    if element1 then writeln('true') else writeln('false');
    writeln(inttostr(element2));
    end;
    end;

    end.

    If you don't know Pascal (but I think everybody here does), I NEED TO ACCESS STRUCTURE ELEMENTS WITHOUT ALWAYS WRITING A STRUCTURE NAME BEFORE "." or "->"

    Please excuse my POOR english...
    Last edited by larry; 09-26-2001 at 12:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pascal.... ??? C# ..... ???
    By Hugo716 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 06-08-2006, 01:01 AM
  2. Pascal
    By cogeek in forum Tech Board
    Replies: 32
    Last Post: 11-20-2004, 04:19 AM
  3. C & Pascal Help
    By Dragon227Slayer in forum C Programming
    Replies: 4
    Last Post: 12-01-2003, 09:40 AM
  4. Compares C++ and Pascal
    By Jaguar in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-19-2002, 11:28 AM
  5. Pascal Compiler
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 04-09-2002, 12:57 AM