Advertisement
EstEsca

Untitled

Oct 4th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include<map>
  2. #include<iostream>
  3. #include<fstream>
  4.  
  5. class Commodity {
  6. private :
  7.   int id_;
  8.   std::string name_;
  9.   int price_;
  10. public :
  11.   Commodity() {
  12.     id_ = 0;
  13.     name_ = std::string("");
  14.     price_ = 0;
  15.   }
  16.   Commodity(int id, std::string name, int price) {
  17.     id_ = id;
  18.     name_ = name ;
  19.     price_ = price;
  20.   }
  21. }
  22.  
  23. class Pos {
  24.   private:
  25.     std::map<int, Commodity> List;
  26.  
  27.   public:
  28.   Pos() {
  29.     std::map<int, Commodity> List;
  30.   }
  31.   "co를 map에 넣어주는 Pos클래스의 함수"{
  32.   }
  33. }
  34.  
  35. int main(){
  36.   Pos 포스기의이름 = pos(); //여기서, Pos라는 형식을 가진, 포스기의이름이라는 객체를, Pos 클래스의 pos()가 말해주는대로 초기화!
  37.  
  38.   std::ifstream commodity("commodity.txt");
  39.   while( commodity>>co_id>>co_name>>co_price) {
  40.     Commodity co( co_id, co_name, co_price);       //commodity.txt의 한줄 한줄의 데이터가 id, name, price에 들어감
  41.     "co를 map에 넣어주는 Pos클래스의 함수"
  42.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement