Write a rest demo (c + +) from scratch

Source: Internet
Author: User

C + + Ah, I was blank, suddenly scheduled a task, C + + to do a demo, used to communicate with the rest server.

Arduous task, every step of the record, for the borrower to borrow.

1. New Win32 Console project, vs2013

2. Install the Boost class library

Boost is a standard library similar to STL, but it expands the STL to make the benefits of generics work best. So now boost is more practical than STL. Since boost is so useful, how do you go about installing the Boost library in the Windows environment?

Let's share the operation I used to configure the Boost_1_55_0 library with VS2013

Tools/Materials
    • Boost

    • VS 2013

Method/Step
    1. Download Boost Library, here I choose to download Boost_1_55_0.zip

    2. Unzip the boost file to a local directory (such as G:\BOOST_1_55_0), and you can find a Bootstrap.bat file in the extracted file.

      Then open the cmd window as an administrator, with the specific commands such as:

    3. After execution of the above command, you can find that G:\boost_1_55_0 a new Bjam.exe file

    4. In the Command window, enter the statement: Bjam.exe. As shown

      This process will by default compile the appropriate Lib files, header files, and so on, based on the compiled tools (vs2008,2010,2012,2013) that the system has already installed. (This step takes about 10 minutes)

    5. You can see Msvc 12.0, because I've already installed VS2013 in my system.

      msvc:8.0 is VS2005.

      msvc:10.0 is VS2010.

      Msvc:12.0 is VS2012, VS2013

    6. After successful execution of the 5th step, you will be prompted with the following information

    7. Now that we have completed the installation of the boost library, we need to configure VS2013 below. Create a new VS2013 console application (project named Boostest) and add the following code

      #include "stdafx.h"

      #include <boost/lexical_cast.hpp>     

      #include <iostream>     

      using namespace std;

      Int main ()

      {

      using Boost::lexical_cast;

      int a = lexical_cast<int> ("123");

      Double b = lexical_cast<double> ("123.0123456789");

      String s0 = Lexical_cast<string> (a);

      String S1 = lexical_cast<string> (b);

      cout << "number:" << a << " " << b << Endl;

      cout << "string:" << s0 << " " << s1 << Endl;

      int c = 0;

      try{

      C = lexical_cast<int> ("ABCD");

      }

      catch (boost::bad_lexical_cast& e) {

      cout << e.what () << Endl;

      }

      return 0;

      }

    8. Add the Include directory and library directory for the Boostest project

      Include directory add G:\boost_1_55_0

      Library Directory Add G:\boost_1_55_0\stage\lib

      Specific as

    9. Enter Code window compile and run successfully instructions The Boost library is indeed configured successfully and can be used with confidence.

      Reference Address: http://jingyan.baidu.com/article/11c17a2c765763f446e39dc1.html

Write a rest demo (c + +) from scratch

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.