Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. typedef struct idx {
  5.     char filename[3];
  6.     char title[47];
  7.     char terminator[2];
  8. }idx_str; // idx ;
  9.  
  10. class DB{
  11.     idx_str *ptr_row;
  12. public:
  13.     DB(){
  14.         //costruttore
  15.     }  
  16.     /*
  17.     ...
  18.     */
  19.     void metodo_che_legge_row_da_file(){
  20.         ptr_row=new idx_str;
  21.         /*
  22.             lettura file secondo le tue esigenze
  23.             ...
  24.             ricorda di accedere ai membri della struct con l'operatore "->"
  25.         */
  26.     }
  27.     idx *return_ptr_row(){
  28.         //metodo che restituisce il puntatore a ptr_row
  29.         return ptr_row;
  30.     }
  31. };
  32.  
  33. int main(){
  34.     DB classe;
  35.     idx_str *record;
  36.     /*
  37.         codice
  38.         ...
  39.     */
  40.  
  41.     classe.metodo_che_legge_row_da_file();//a questo punto stai popolando la tua struct da file
  42.     /*
  43.         codice
  44.         ...
  45.     */
  46.     record=classe.return_ptr_row(); //a questo punto a qualcuno interessa leggere la struct popolata precedentemente
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement