#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; }
练习13.14 13.15 13.16,布布扣,bubuko.com
时间: 2024-10-24 14:28:25