#include <string> #include <iostream> #include <vector> #include <memory> struct Numbered { //! for ex13.14 Numbered() { static unsigned i = 0; ++i; mySn = i; } //! for ex13.15 Numbered(const Numbered&) { static unsigned j = 99; ++j; mySn = j; } unsigned mySn; }; //void f (Numbered s) //! void f(const Numbered& s) { std::cout << s.mySn << std::endl; } int main() { Numbered a, b = a, c = b; f(a); f(b); f(c); return 0; }
时间: 2024-10-25 22:03:53