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

📄 const.cpp

📁 c21Examples.rar
💻 CPP
字号:
//Using constructors and destructors
#include <iostream.h>

class value {
private:
    int val;
public:
    int get_value();
    value(int nbr = 99);
    ~value();
};

int main(int argc, char* argv[])
{
    cout << "\nGetting ready to declare myValue...";

    value myValue;

    cout <<"\nmyValue is now declared...";

    cout <<"\n\nPrinting myValue: " << myValue.get_value();

    cout << "\n\nEnding program.";

    return 0;
}

int value::get_value()
{
    return val;
}

// Contructor for value class
//----------------------------
value::value( int nbr )
{
    // Do initializations.
    val = nbr;
    cout << "\n...In the constructor...\n";
}

// Destructor for value class
//----------------------------
value::~value()
{
    // No real logic here for this class
    cout << "\n...In the destructor...\n";
}

⌨️ 快捷键说明

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