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)?
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?
(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
Post a Comment