From b8338b0528db21ddcb669c80fdcf8672094843ce Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Wed, 12 Mar 2025 15:48:27 +0100 Subject: [PATCH] Added explanation for usage of CHECK macro in exercises --- exercises/classes/classes.cpp | 4 ++++ exercises/classes/solution/classes_sol.cpp | 4 ++++ exercises/operators/operators.cpp | 4 ++++ exercises/operators/solution/operators_sol.cpp | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/exercises/classes/classes.cpp b/exercises/classes/classes.cpp index e3cba9fe..05bd5dc4 100644 --- a/exercises/classes/classes.cpp +++ b/exercises/classes/classes.cpp @@ -35,6 +35,10 @@ class Fraction { // ADD YOUR CODE HERE +// This is using the cpp, the C preprocessor to expand a bit of code +// (the what argument) to a pair containing a string representation +// of it and the code itself. That way, print is given a string and a +// value where the string is the code that lead to the value #define CHECK(print,what) print(#what, what) unsigned int WIDTH {20}; diff --git a/exercises/classes/solution/classes_sol.cpp b/exercises/classes/solution/classes_sol.cpp index f85f5c9b..7b0f38b5 100644 --- a/exercises/classes/solution/classes_sol.cpp +++ b/exercises/classes/solution/classes_sol.cpp @@ -53,6 +53,10 @@ class TestResultPrinter { }; +// This is using the cpp, the C preprocessor to expand a bit of code +// (the what argument) to a pair containing a string representation +// of it and the code itself. That way, print is given a string and a +// value where the string is the code that lead to the value #define CHECK(printer,what) printer.process(#what, what) int main() { diff --git a/exercises/operators/operators.cpp b/exercises/operators/operators.cpp index caa361c2..625c9c25 100644 --- a/exercises/operators/operators.cpp +++ b/exercises/operators/operators.cpp @@ -58,6 +58,10 @@ class TestResultPrinter { }; +// This is using the cpp, the C preprocessor to expand a bit of code +// (the what argument) to a pair containing a string representation +// of it and the code itself. That way, print is given a string and a +// value where the string is the code that lead to the value #define CHECK(printer,what) printer.process(#what, what) int main() { diff --git a/exercises/operators/solution/operators_sol.cpp b/exercises/operators/solution/operators_sol.cpp index a03fda7e..2ec53056 100644 --- a/exercises/operators/solution/operators_sol.cpp +++ b/exercises/operators/solution/operators_sol.cpp @@ -69,6 +69,10 @@ class TestResultPrinter { }; +// This is using the cpp, the C preprocessor to expand a bit of code +// (the what argument) to a pair containing a string representation +// of it and the code itself. That way, print is given a string and a +// value where the string is the code that lead to the value #define CHECK(printer,what) printer(#what, what) int main() {