Topic: With statement in C++ ?


Author: "TytySoft" <amoga@aspdeveloper.net>
Date: 1997/09/19
Raw View
A: not really.

but take a look:

// --- "sample.cpp"

struct C
 {
  int action1(){ return 1; }
  int action2(){ return 2; }
  int action3(){ return 3; }
 };

 struct B
 {
  C c;
 };

 struct A
 {
  B b;
 };

 void f(void)
 {
  A a;
  C& rc = a.b.c;

  rc.action1(); // same as a.b.c.action1()
  rc.action2(); // same as a.b.c.action2()
  rc.action3(); // same as a.b.c.action3()
}


hope it helps,
Augustin MOGA (aka { t i T i } )


Cristian Georgescu wrote in article
<01bcc3e5$b2f10bc0$203174cf@worldnet.worldnet.att.net>...

>Q: With statement in C++ ?
>================
>
>Is there a way to mimic a with statement in c++:
>
>Instead of:
>
>a.b.c.action1();
>a.b.c.action2();
>a.b.c.action3();
>a.b.c.action4();
>
>Write:
>
>with a.b.c {
> .action1();
> .action2();
> .action3();
> .action4();
>}
>
>
>--
>Cristian Georgescu
>_________________________________________________
>    Smith Industries
>    Aerospace & Defense Systems
>    7-9 Vreeland Road,
>    Florham Park, NJ 07932, USA.
>_________________________________________________
>E-mail: Georgescu_Christian@si.com
>---
>[ comp.std.c++ is moderated.  To submit articles: try just posting
     ]
>[ your news-reader.  If that fails, use
td-c++@ncar.ucar.edu         ]
>[ FAQ:
  http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
>[ Policy:
http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
>[ Comments?
ucar.edu                             ]
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]