#include<iostream> #include<vector> using namespace std; /* class Sales_item { public: double avg_price()const; bool same_isbn(const Sales_item &rhs) const { return isbn == rhs.isbn; } Sales_item(): units_sold(0), revenue(0.0) { }//构造函数 private: string isbn; unsigned units_sold; double revenue; }; double Sales_item::avg_price()const { if(units_sold) return revenue/units_sold; else return 0; } */ /* class Screen { public: typedef std::string::size_type index; index func(int a.int b); private: index heghit,wight; std::string contents; std::string::size_type cursor; //std::string::size_type heghit,wight; protected: }; inline Screen::index Screen::func(Screen::index a,Screen::index b) { return a+b; } */ /* class Screen { public: // interface member functions Screen& move(index r, index c); Screen& set(char); Screen& set(index, index, char); Screen& display(iostream &os) { do_display(os); return *this; } // other members as before private: Screen& do_display(iostream &os)const { //do something displsy os<<"what is the func!!"<<endl; } }; */ /* int hight; class aa { public: int diaoyong(int hight) { return hight; } int diaoyong1(aa::hight) { return hight; } int diaoyong2(::hight) { return hight; } private: int hight,with; protected: }; */ //构造函数 /* class sales_item { public: //sales_item():b(2){} explicit sales_item(int& c ):b(c){} explicit sales_item(istream& ist); void m_cout() { cout<<this->b<<endl; } private: int b; std::string a; int revenue; }; sales_item::sales_item(istream& ist) { ist>>b; } */ //友元,friend /* class screen { friend class win_con; public: protected: private: int a; string b; char c; }; class win_con { public: win_con& control(screen &s); }; win_con& win_con::control(screen &s){ s.a+=1; return *this; } */ //static int main() { //vector<int> a; //sales_item my_sales(cin); //int x=5; //sales_item my_sales(x); //my_sales.m_cout(); system("pause"); return 1; }
时间: 2024-10-11 07:14:31