⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function-call.cpp

📁 压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架>>所有源码
💻 CPP
字号:
#include <iostream>using namespace std;//start id=classdefclass SignatureDemo {public:    SignatureDemo(int val) : m_Val(val) {}    void demo(int n)        {cout << ++m_Val << "\tdemo(int)" << endl;}    void demo(int n) const /* overloaded on const-ness */          {cout << m_Val << "\tdemo(int) const" << endl;}/*  void demo(const int& n)         {cout << ++m_Val << "\tdemo(int&)" << endl;}  */ /* clashes      with previous function */    void demo(short s)          {cout << ++m_Val << "\tdemo(short)" << endl;}    void demo(float f)          {cout << ++m_Val << "\tdemo(float)" << endl;}    void demo(float f) const         {cout << m_Val << "\tdemo(float) const" << endl;}    void demo(double d)        {cout << ++m_Val << "\tdemo(double)" << endl;}private:    int m_Val;};//end//start id=clientcodeint main() {    SignatureDemo sd(5);    const SignatureDemo csd(17);    sd.demo(2);        csd.demo(2);   /* const version is called. */    int i = 3;    sd.demo(i);    short s = 5;    sd.demo(s);    csd.demo(s); /* Non-const short can not be called,                so a promotion to int is required to call                the const int version. */    sd.demo(2.3);   /* This is double, not float. */    float f(4.5);       sd.demo(f);    csd.demo(f);        csd.demo(4.5);      return 0;}//end 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -