C++ All-in-One For Dummies
Book image
Explore Book Buy On Amazon
The static library starts with a standard C file. To make this library work well with templates, you need to delete the C file, add a C++ file, and add a header file. The following steps describe how to perform this process:

Right-click main.c in the Projects tab of the Management window and choose Remove File From Project from the context menu that appears.

Code::Blocks removes the file from the project tree.

Choose File→New→File.

Choose File→New→File.

You see the New from Template dialog box shown.

Highlight the C/C++ Header icon and click Go.

You see the Welcome page of the C/C++ Header wizard.

Click Next.

Click Next.

The wizard asks you to provide the header configuration information.

In the Filename with Full Path field, type MathLibrary.h, click the ellipses button, and then click Save.

Code::Blocks adds the complete project path to the filename you chose. Notice that Code::Blocks also supplies an entry for the Header Guard Word field. This word ensures that the header isn’t added more than once to a project.

Click All, and then click Finish.

The C/C++ Source wizard adds the file to your project. You’re ready to begin creating a template library.

About This Article

This article is from the book:

About the book author:

John Mueller has published more than 100 books on technology, data, and programming. John has a website and blog where he writes articles on technology and offers assistance alongside his published books.

Luca Massaron is a data scientist specializing in insurance and finance. A Google Developer Expert in machine learning, he has been involved in quantitative analysis and algorithms since 2000.

This article can be found in the category: