Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pages 108, 110, and 111: The given console output of SimpleStringOwner on page 111 is wrong relative to the prior code. #77

Closed
WraithGlade opened this issue Dec 25, 2019 · 1 comment

Comments

@WraithGlade
Copy link

@WraithGlade WraithGlade commented Dec 25, 2019

Page 111 claims that this code:

int main() { 
    SimpleStringOwner x{ "x" }; 
    printf("x is alive\n"); 
}

...will print "Constructed: x" (etc) but it actually won't.

It will instead print "Constructed: : x" (etc) due to the contents of the source code on pages 108 and 110.

The original SimpleString code already adds a colon and a space to tags for its tagged print function, but the later code is designed as if this wasn't the case. These two sections of the book are probably from different revisions of the book that were created during its writing.

Here's the original print function from SimpleString:

void print(const char* tag) const { 
    printf("%s: %s", tag, buffer); 
}

...and here's how it is used later:

string.print("Constructed: ");

(etc)

Notice the implications of that.

@JLospinoso JLospinoso closed this in fc1ff45 Jan 1, 2020
@JLospinoso

This comment has been minimized.

Copy link
Owner

@JLospinoso JLospinoso commented Jan 1, 2020

Thanks, @WraithGlade!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.