pg: 172-175 Multiple Interfaces, Stroustrup, C++ Programming Language, 3E -
i having difficulty making sense of this! trying in this?
page 172-173, create single namespace 2 interfaces (parser, parser-prime). stick each interface in different header file (parser-implementer.h , parser-user.h). parser-user.h has smaller namespace definition , parser-implementer.h has larger (implementer) namespace definitions. why that: "compiler doesn't have sufficient information check consistency of 2 definitions of namespace."?? if actual implementation in: parser-crud.c, should: #include <parser-implementer>
way compiler guarantee c-definitions matched declarations in header.. of course parser-user.h not checked.. he's saying??
then on pg:174(lower half), how parser_interface dependent on parser::expr?? doing here???? doing:
#include <parser-implementer.h> // gets namespace parser scope namespace parser_interface { using parser::expr; }
pg 175 (top line) how driver "vulnerable" change in parser_interface interface????
i don't understand after either (till page 176 top).. explain in terms of header files, #include, , make-dependencies??
can have two:
namespace foo { bar }; namespace foo { baz };
definitions within 1 header file??
let's start namespaces. must understand if have 2 header file class cube_impl.h , cube.h both can have
namespace cube { ... }
the namespace unique , define once. not declaring 2 namespaces of same name, using same namespace twice. thus, written inside namespace part of it. can use namespace in multiples other class if suits you. can accessed
cube::functionname
concerning use of "user" interface , "implementer" interface.
this neat thing professional use when want hide implementation user. create first header file contains public members/functions user (e.g. cube.h). then, create header file "implementation" (e.g. cube_impl.h) protected , private members/functions declared.
the benefits can later on change cube_impl.h without affecting user since don't know code present there.
i didn't read book referring to, hope answer question.
regards
Comments
Post a Comment