Summary of the usage skills of C ++ programming ideology

Source: Internet
Author: User

(1) print expression

When writing debugging code, writing a print expression consisting of a variable name and a string array followed by the variable name is boring. Fortunately, standard C has a string operator '#', the Preprocessor converts this parameter to an array of characters. Link this point with a combination of several characters without punctuations into a separate character array, which can generate a very convenient macro for printing the variable value during debugging:

# Define PR (x) cout <# X "=" <x <Endl;

Example:

//: C03: stringizingexpressions. CPP // from thinking in C ++, 2nd Edition // available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // copyright notice in copyright.txt # include <iostream> using namespace STD; # define P (a) cout <# A <":" <(a) <Endl; int main () {int A = 1, B = 2, C = 3; P (A); P (B); p (c); P (A + B); P (c-a)/B ); system ("pause ");}///:~

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.