From 98d21f87cbba2db4dce2cc5b18103dea3976e4b4 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 18 Jan 2024 18:01:53 -0500 Subject: [PATCH] adding notes on include guards --- hws/02_ride_sharing/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hws/02_ride_sharing/README.md b/hws/02_ride_sharing/README.md index 2f67af5..801dc80 100644 --- a/hws/02_ride_sharing/README.md +++ b/hws/02_ride_sharing/README.md @@ -313,6 +313,21 @@ nyride.exe drivers.txt riders.txt search driver_id ``` --> +## Include Guards + +If you are writing more than one class, you may run into strange compiler errors when you compile everything. This may be due to a problem with including your class files, which can be solved as follows: for a header file called myclass.h add these two lines at the very top of the header file: + +```cpp +#ifndef __MYCLASS_H +#define __MYCLASS_H +``` + +and at the very bottom of your .h file, add this line: + +```cpp +#endif +``` + ## Program Requirements & Submission Details Use good coding style when you design and implement your program. Organize your program into functions: