Inline functions for C ++ Learning

Source: Internet
Author: User

Inline Function Learning.

# Include <iostream> # include <string> # include <fstream> using namespace STD; # define f (x) (x + 1) # define floor (X, B) (x)> = (B )? ) // The benefit of parentheses # define band (x)> 5 & (x) <10? (X): 0) inline int plusone (int x) {return ++ X;} // The Inline Function in C ++ replaces the macro class point {int I, j, k; public: Point (): I (0), J (0), K (0) {} Point (INT II, int JJ, int KK ): I (ii), J (jj), K (kk) {} inline void print (const string & MSG = "") const // inline function {If (MSG. size ()! = 0) cout <MSG <Endl; cout <"I =" <I <"," <"J =" <j <", "<" k = "<k <Endl ;}}; class forward {int I; public: Forward (): I (0) {} int kk () const {return g () + 1 ;}// ------------- forward reference int g () const {return I ;}}; class access {int I; public: int read () const {return I;} // inline function improves efficiency int set (int ii) {I = II ;}}; int main () {point P, Q, 3); p. print ("value of P"); q. print ("value of Q"); Forward frwd; frwd. kk (); Return 0 ;}

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.