Pointer, Referencing, and Dereferencing confusion

I am in my 3rd consecutive computer class in college and I still am struggling immensely in understanding why, when and how to use the operators *, &, and ->. Currently I am working on using Insertion, Merge and Quick sorts to analyze the time differences to sort massive amounts of data. But I am having trouble accessing the vector in the header file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class CensusData {
public:
   static const int POPULATION = 0;       // type of sort
   static const int NAME = 1;
   ~CensusData();
   void initialize(ifstream&);            // reads in data
   int getSize(){return data.size();}
   void print();                          // prints out data
   void insertionSort(int);               // sorts data using insertionSort
   void mergeSort(int);                   // sorts data using mergeSort
   void quickSort(int);                   // sorts data using quickSort
private:
   class Record {                         // declaration of a Record
   public:
      string* city;
      string* state;
      int population;
      Record(string&, string&, int);
      ~Record();
   };
   vector<Record*> data;                  // data storage
   //
   // Insert private helper functions here
   //
};
* Asterisk is used for Dereferencing a pointer.. means accessing the value or data a pointer is pointing to.. similarly for -> means the same but like we do Student.Roll_no in a class of student to access the Roll_no in same way we use -> to access the pointer member of any class
Topic archived. No new replies allowed.