本文整理汇总了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(®ular->ifile, "file1");
regular->setContent(®ular->ifile, "this is file1.");
directory->add(&directory->ifile, ®ular->ifile);
regular = new(Regular);
regular->setName(®ular->ifile, "file2");
regular->setContent(®ular->ifile, "this is file2.");
directory->add(&directory->ifile, ®ular->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(®ular->ifile),
regular->getContent(®ular->ifile));
file = directory->getChild(&directory->ifile, "file2");
regular = container_of(file, Regular, ifile);
printf("file name: %s, file content: %s\n",
regular->getName(®ular->ifile),
regular->getContent(®ular->ifile));
delete(Directory, directory);
return 0;
}
示例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";
}
示例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"];
}