Create a static library project 1. create a static project MathFucsLib: select the win32 console application> enter the MathFuncsLib Project Name> next> select static library; cancel the default pre-compilation header> finish 2. add the class MyMathFuncs to the static library: [cpp] # pragma once // MathFuncsLib. h namespace MathFuncs {class MyMathFuncs {public: static double Add (double a, double B); static double Substract (double a, double B); static double Multiply (double, double B); static double Divide (double a, double B) ;}}// MathFuncsLib. cpp # include "MathF UncsLib. h "# include <stdexcept> using namespace std; namespace MathFuncs {double MyMathFuncs: Add (double a, double B) {return a + B;} double MyMathFuncs :: substract (double a, double B) {return a-B;} double MyMathFuncs: Multiply (double a, double B) {return a * B;} double MyMathFuncs :: divide (double a, double B) {if (B = 0) {throw new invalid_argument ("B cannot be zero! ");} Return a/B;} 3. confirm that the lib file is generated: Project, property-> Configuration property, General-> configuration type: changed to static library (. lib); compile and generate MathFuncsLib. lib creates a console application that references the static library. 1. create a console application that references the static library: add the project MyExecRefsLib to the same solution: Select win32 console application> enter MyExecRefsLib Project Name> next> select console application; cancel the default pre-compilation header-> finish 2. in the application, use the static library function 2.1 to add the header file directory so that the header file contained in the program exists (that is, it can be found): Project, property-> C/C ++-> General-> additional include directory :.. \ MathFuncsLib or: Project properties-> VC ++ directory-> include directory :.. \ MathFuncsLib2.2 add. reference a project in the lib file, reference-> general properties-> framework and reference-> Add reference-> the project name and project directory of MathFuncsLib are displayed-> OK or, add library directory and additional library: Project, properties-> connector-> General-> additional library Directory: for example, $ (OutDir) project, property-> connector-> input-> additional dependency: MathFuncsLib. lib3. the program uses [cpp] # include <iostream> using namespace std; # include "MathFuncsLib. h "int main () {double a = 7.4; int B = 99; cout <" a + B = "<MathFuncs: MyMathFuncs: Add (a, B) <endl; cout <"a-B =" <MathFuncs: MyMathFuncs: Substract (a, B) <endl; cout <"a * B =" <MathFuncs: MyMathFuncs: Multiply (a, B) <endl; cout <"a/B =" <MathFuncs:: MyMathFuncs: Divide (a, B) <endl; return 0 ;}4. set MyExecRefsLib as the startup project and press Ctrl + F5