main.cpp

来自「C++ Source code from a tutorial」· C++ 代码 · 共 57 行

CPP
57
字号
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

namespace Work {

    int FavoriteNumber;
    
    class Info {
    public:
        string CompanyName;
        string Position;
    };
    
    void DoStuff() {
        cout << "Doing some work!" << endl;
    }
}


namespace Play {

    int FavoriteNumber;
    
    class Info {
    public:
        string FullName;
        string Hobby;
    };
    
    void DoStuff() {
        cout << "Having fun!" << endl;
    }
}

int main(int argc, char *argv[])
{
    // Work stuff
    Work::FavoriteNumber = 7;
    Work::Info WorkInformation;
    WorkInformation.CompanyName = "Spaceley Sprockets";
    WorkInformation.Position = "Worker";
    Work::DoStuff();
    
    // Play stuff
    Play::FavoriteNumber = 13;
    Play::Info PlayInformation;
    PlayInformation.FullName = "George Jetson";
    PlayInformation.Hobby = "Playing with the dog";
    Play::DoStuff();
    
    system("PAUSE");	
    return 0;
}

⌨️ 快捷键说明

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