int main(int argc, char** argv) { qRegisterMetaType<ComponentA>("ComponentA"); qRegisterMetaType<ComponentB>("ComponentB"); Node base; base.AddChild(new Node)->AddComponent(new ComponentA); base.AddChild(new Node)->AddChild(new Node); Node* n = base.AddChild(new Node); n->AddComponent(new ComponentA); n->AddComponent(new ComponentB); //base.Display(); // // yaml test YAML::Emitter out; out << YAML::BeginMap; out << YAML::Key << "metadata" << YAML::Value; out << YAML::BeginMap; out << YAML::Key << "author" << YAML::Value << "opatut"; out << YAML::Key << "date" << YAML::Value << "2011-10-23"; out << YAML::EndMap; out << YAML::Key << "rootnode" << YAML::Value; base.Serialize(out); std::string yaml(out.c_str()); std::cout << "Output YAML:" << std::endl << "========" << std::endl; std::cout << yaml << std::endl; std::cout << "Base:" << std::endl << "========" << std::endl; base.Display(); std::istringstream stream; stream.str(yaml); YAML::Parser parser(stream); YAML::Node doc; parser.GetNextDocument(doc); Node* read = Node::Deserialize(doc["rootnode"]); std::cout << "Read:" << std::endl << "========" << std::endl; read->Display(); return 0; }
//Главна функция int main() { cout<<fin(6)<<endl; int b = 0; if (!b) { cout<<"fgfg"<<endl; } if (b == 0) { cout<<"BB"<<endl; } Node *pNode = 0; CAT * pCat = new CAT(0); int age; Node *pHead = new Node(pCat); while (1) { cout << "New Cat's age? (0 to quit): "; cin >> age; if (!age) { break; } pCat = new CAT(age); pNode = new Node(pCat); pHead->Insert(pNode); } //int age = pHead->GetCat().GetAge(); //cout<<age; pHead->Display(); cout<<pHead->Sum(); delete pHead; cout << "Exiting...\n\n"; return 0; }
//Член функция за извеждане на подредените по възраст котки void Node::Display() { if (itsCat->GetAge() > 0) { cout << itsCat->GetAge() << " years old\n"; } if (itsNext) { itsNext->Display(); } }