infact构建 C++ 实例类
Infact 提供一个构建 C++ 实例的类,它的语法和 C++的很像,创建的对象可以用来封装其他对象,就像 C++ 那样。它支持通用的私有类型(bool、int、double、string)。
示例代码:
// Construct a cow with a required argument, its name. Cow c1 = Cow(name("Bessie")); // Construct a second cow with a different name, and an optional age. // Also, specifying a type is optional, since InFact does type inference. c2 = Cow(name("Lani Moo"), age(2)); // Construct a human pet owner with the two cows as pets. PetOwner p = HumanPetOwner(pets({c1, c2}));
评论