例子
#include <iostream>#include <string>using namespace std;struct student { string sno; student() { cout << "调用构造函数son为:" << sno << "#"<<endl; } student(string sno) { this->sno = sno; cout << "调用构造函数sno为:" << this->sno << "#" << endl; } void Operator()(string sno) { this->sno = sno; cout << "调用函数对象sno为:" << this->sno << "#" << endl; }};int main(){ student s("2014");//输出"调用构造函数sno为:2014#" student s2; //输出"调用构造函数sno为:#" s("2014"); //输出"调用函数对象sno为:2014#" getchar(); return 0;}新闻热点
疑难解答
图片精选