当前位置: 首页>>代码示例>>C++>>正文


C++ Directory::add方法代码示例

本文整理汇总了C++中Directory::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Directory::add方法的具体用法?C++ Directory::add怎么用?C++ Directory::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Directory的用法示例。


在下文中一共展示了Directory::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    Directory* directory = new(Directory);
    directory->setName(&directory->ifile, "directory");

    Regular* regular = new(Regular);
    regular->setName(&regular->ifile, "file1");
    regular->setContent(&regular->ifile, "this is file1.");
    directory->add(&directory->ifile, &regular->ifile);

    regular = new(Regular);
    regular->setName(&regular->ifile, "file2");
    regular->setContent(&regular->ifile, "this is file2.");
    directory->add(&directory->ifile, &regular->ifile);

    printf("directory name: %s\n", directory->getName(&directory->ifile));

    IFile* file = directory->getChild(&directory->ifile, "file1");
    regular = container_of(file, Regular, ifile);
    printf("file name: %s, file content: %s\n",
           regular->getName(&regular->ifile),
           regular->getContent(&regular->ifile));

    file = directory->getChild(&directory->ifile, "file2");
    regular = container_of(file, Regular, ifile);
    printf("file name: %s, file content: %s\n",
           regular->getName(&regular->ifile),
           regular->getContent(&regular->ifile));

    delete(Directory, directory);
    return 0;
}
开发者ID:jhpeng,项目名称:DesignPatternExample,代码行数:32,代码来源:main.c

示例2: TrackableObject

TEST(UnfixturedDirectoryTest, ObjectsAreDeletedWhenDirectoryIsDeleted)
{
    Directory<std::string, TrackableObject> *directory = new Directory<std::string, TrackableObject>("Directory");
    TrackableObject *t1 = new TrackableObject();
    ASSERT_EQ(TrackableObject::getInstances(), 1);
    directory->add("key", t1, 100);
    ASSERT_EQ(TrackableObject::getInstances(), 1) << "Directory copied / deleted object";
    delete directory;
    ASSERT_EQ(TrackableObject::getInstances(), 0) << "Directory did not delete Object when it was deleted";
}
开发者ID:icyerasor,项目名称:joynr,代码行数:10,代码来源:DirectoryTest.cpp

示例3: main

int main() {
    
    // Model as if there are these four kinds
    // of position in the problem:
    Position boss("Boss", 3141.59);
    Position pointyHair("Pointy Hair", 271.83);
    Position techie("Techie", 14142.13);
    Position peon("Peonissimo", 34.79);
    
    // 
    Directory d;
    d.add("Marilyn", 123, 4567, boss);
    //d.add("John", 321, 7654, boss);
    //d.add("Bob", 234, 9876, boss);
    cout << d << endl;
    Directory d2 = d;	// What function is being used.
    d2.add("Gallagher", 111, 2222, techie);
    cout << d2 << endl;
    Directory d3;
    d3 = d2;
    cout << d3 << endl;

    cout << d3["Marilyn"];
}
开发者ID:NoKnowledge,项目名称:cplusplus,代码行数:24,代码来源:rec09.cpp


注:本文中的Directory::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。