例子
#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;}新聞熱點
疑難解答
圖片精選