c++ - pg:172-176.PartA.Interface Design Alternatives, Stroustrup-CPL-3E -


on page 172, stroustrup doing so:

  namespace parser {   //interface users     double expr(bool);   }    namespace parser { //interface implementers     double prim(bool);     double term(bool);     double expr(bool);      using lexer::get_token;     <snip>   } 

q1. imply first namespace being inserted (as example) user.h , included main.cpp - driver; second namespace implementer.h , included parse.cpp? why says:

"compiler doesn't have sufficient information check consistency of 2 definitions of namespace"

  • because both implementer.h , user.h can't included "parser implementation"(parse.cpp)?

172.png 173.png

on page 174, has:

  namespace parser {   //interface implementers     // ...     double expr(bool);    // ...   }    namespace parser_interface { //interface users     using parser::expr;   } 

is upper namespace going implementer.h , lower 1 user.h

in "dependency graph" restating obvious: when make run, change "parser"(parser.cpp/implementer.h) result in driver/main.cpp being rebuilt - unnecessarily?

174.png

http://groups.google.com/group/alt.comp.lang.learn.c-c++/browse_thread/thread/3be9f35f2969f311/0d418ec6138a7e58#0d418ec6138a7e58

(the part compiler consistency wrong , above thread states why: yes, implementation can , should that, checking of consistency works extent. if user.h uses things not declared there, diagnostic. if have "double expr(bool);" declared in 1 place , "float expr(bool);" in another, compiler should give diagnostic. however, if change second 1 "float expr(int);", overload legal c++. - ulrich eckhardt)


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -