See More

#include #include #include #include #include #include #include #include #include "Blob.h" using namespace std; void ShowItem(BaseItem& item) { cout<<"Item id: "< (b) ? (a) : (b)) template inline void MaxValue(const T& a, const T& b) { ShowItem(a > b ? a : b); } template int compare(const T& left, const T& right) { if (left < right) return -1; if (left > right) return 1; return 0; } template T calc(const T& a, const U& b) { T tmp = a + b; return tmp; } template int compare(const char (&p1)[N], const char (&p2)[M]) { return strcmp(p1, p2); } void ManageObjects(int count) { std::tr1::shared_ptr pItem(new BaseItem(5)); std::tr1::shared_ptr pItem2(pItem); // pItem2指向对象,pItem也指向对象,引用计数为2 pItem = pItem2; // pItem2指向对象,pItem也指向对象 pItem2->Print(); pItem->Print(); //.... if(0 == count) { return ; } } int main() { char szbuff[MAX_ITEM_COUNT] = {0}; cout << "main:" << (&MAX_ITEM_COUNT) << endl; char szInfo[50] = {0}; float fValue = 6.625f; int nPresion = 2; //fValue += 5/pow(10,nPresion+1); sprintf(szInfo, "%.*f", nPresion, fValue); cout << szInfo << endl; //ShowItem(34); Game cod; Game gta(cod); gta.SetName("gta"); cod = gta; cod.Print(); ManageObjects(0); compare("good", "god"); Blob squares = {0, 1, 2, 3, 4, 5}; for (size_t i = 0; i != squares.size(); i++) { squares[i] = i*i; } getchar(); return 0; }