简体   繁体   中英

How do you add a class in your C++ directory?

I've been completing the exercises in a book to learn C++.

Exercise 1.20: http://www.informit.com/title/032174113 contains a copy of Sales_item.h in the Chapter 1 code directory. Copy that file to your working directory. Use it to write a program that reads a set of book sales transactions, writing each transaction to the standard output.

First off, the link they provided wasn't working. However, I got around this by finding the code on GitHub. However, I am extremely confused on how to add this to my directory. To be honest, I don't even know what that means? Could someone please explain how to add this code into your library?

id doesn't say "add to your directory", it says "copy that file to your working directory". Your working directory is the directory you put all your *.cpp and .h and project files in.

If it is what i'm thinking, do the following.

-Copy the Sales_item.h file to your working directory(probably where your code is) -Include the Sales_item.h file in your program using:

       #include "Sales_item.h"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM