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

📄 main.cpp

📁 C++ Source code from a tutorial
💻 CPP
字号:
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

class Book {
public:
    string Name;
    string Author;
    string Publisher;
    Book(string aname, string anauthor, string apublisher) :
        Name(aname), Author(anauthor), Publisher(apublisher)
        {}
};

class Magazine {
public:
    string Name;
    string Issue;
    string Publisher;
    Magazine(string aname, string anissue, 
        string apublisher) :
        Name(aname), Issue(anissue), Publisher(apublisher)
        {}
};

template <typename T>
class MediaHolder {
public:
    T *array[100];
    int Count;
    void Add(T *item) {
        array[Count] = item;
        Count++;
    }
    MediaHolder() : Count(0) {}
};

class BookHolder : public MediaHolder<Book> {
public:
    enum GenreEnum {childrens, scifi, 
    romance, horror, mainstream, hownotto};
    
    GenreEnum GenreOfAllBooks;
};

class MagazineHolder : public MediaHolder<Magazine> {
public:
    bool CompleteSet;
};

int main(int argc, char *argv[])
{
    MagazineHolder dl;
    dl.Add(new Magazine(
        "Dummies Life", "Vol 1 No 1", "Wile E."));
    dl.Add(new Magazine(
        "Dummies Life", "Vol 1 No 2", "Wile E."));
    dl.Add(new Magazine(
        "Dummies Life", "Vol 1 No 3", "Wile E."));
    dl.CompleteSet = false;
    cout << dl.Count << endl;
    
    BookHolder bh;
    bh.Add(new Book(
        "CEOing for Dumdums", "Gookie Dan", "Wile E."));
    bh.Add(new Book(
        "Carsmashing for Dumdums", "Woodie and Buzz", 
        "Wile E."));
    bh.Add(new Book(
        "Turning off the Computer for Dumdums", 
        "Wrath of Andy",
        "Wile E."));
    bh.GenreOfAllBooks = BookHolder::hownotto;
    cout << bh.Count << endl;
        
    system("PAUSE");
    return 0;
}


⌨️ 快捷键说明

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