-
Notifications
You must be signed in to change notification settings - Fork 0
C++ experiment #24
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
base: master
Are you sure you want to change the base?
C++ experiment #24
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new section about C++ and Java to a literate programming tutorial, demonstrating compilation errors and the use of the -L flag in noweb for better error reporting. The main focus is showing how literate programming tools can maintain source file references in compiler error messages.
Key changes:
- Adds comprehensive C++ fraction class example with constructor, operators, and string conversion
- Demonstrates noweb's
-Lflag functionality for preserving line number references in compilation errors - Includes Java comparison section (placeholder)
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| whatis/whatis.nw | Adds new section reference for C++/Java content |
| whatis/introsort.nw | Minor documentation improvements and cross-references |
| whatis/cppjava.nw | New comprehensive C++ example with fraction class implementation |
| whatis/abstract.tex | Removes comment markers and fixes citation format |
| whatis/Makefile | Adds build rules for C++ examples and dependencies |
| whatis/.gitignore | Adds generated files to ignore list |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| <<headers to include>>= | ||
| #include <iostream> | ||
| <<function declarations>>= | ||
| std::ostream& operator<<(std::ostream& os, const Fraction& f); |
Copilot
AI
Sep 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The operator<< declaration should be placed in the header file (fraction.h) under a <<function declarations>> section, not just in the implementation file. This ensures the function is properly declared for external use.
| std::ostream& operator<<(std::ostream& os, const Fraction& f) { | ||
| os << f.to_string(); | ||
| return os; | ||
| } |
Copilot
AI
Sep 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The operator<< implementation calls a public method to_string() but could directly access private members if declared as a friend function, which would be more conventional for stream operators. However, the current approach maintains encapsulation and works correctly.
| Fraction(int numerator, int denominator); | ||
|
|
||
| <<method declarations>> | ||
| <<overloaded operator declarations>> |
Copilot
AI
Sep 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The <<function declarations>> section is referenced but never defined in the header file structure. The operator<< declaration should be included in the header file for proper compilation.
Tries to have
<<overload as notfriend.