Changeset 8617ee90 for doc/uC++toCFA


Ignore:
Timestamp:
Mar 15, 2025, 1:42:40 PM (2 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
8f250e0
Parents:
06ffa95
Message:

update constructor/destructor section for uC++toCFA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified doc/uC++toCFA/uC++toCFA.tex

    r06ffa95 r8617ee90  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sat Feb  1 12:36:30 2025
    14 %% Update Count     : 6285
     13%% Last Modified On : Sat Mar 15 13:38:53 2025
     14%% Update Count     : 6302
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    397397struct S {
    398398        int i, j;
    399 
     399        @S@() { i = j = 3; }
    400400        @S@( int i, int j ) { S::i = i; S::j = j; }
     401        @S@( const S & s ) { *this = s; }
    401402        @~S@() {}
    402403};
     404S s0;
    403405S s1 = { 1, 2 };
    404406
     
    415417\begin{cfa}
    416418#include <stdlib.hfa> // new (malloc)
    417 struct S {
    418         int i, j;
    419 };
    420 void @?{}@( S & s, int i, int j ) { s.i = i; s.j = j; }
    421 void @^?{}@( S & s ) { s.i = 0; s.j = 0; }     
    422 
     419struct S { int i, j; };
     420
     421void @?{}@( S & s ) { s.i = s.j = 3; } $\C[3in]{// default}$
     422void @?{}@( S & s, int i, int j ) { s.i = i; s.j = j; } $\C{// initializer}$
     423void @?{}@( S & s, const S rhs ) { s.[i,j] = rhs.[i,j]; } $\C{// copy}$
     424void @^?{}@( S & s ) { s.i = 0; s.j = 0; } $\C{// destructor}\CRT$
     425
     426S s0;
    423427S s1 = { 1, 2 };
    424428// cannot use 0/1 (zero_t/one_t) with "new"
     
    428432delete( s2 );
    429433S & s3 = *new( 1n, 2 );
    430 delete( s3 );
     434delete( &s3 );
    431435&s3 = &*new( 1n, 2 );
    432 delete( s3 );
     436delete( &s3 );
    433437\end{cfa}
    434438\end{tabular}
Note: See TracChangeset for help on using the changeset viewer.