Hi,
I am new to C++, and I think it will take several years for me to
be profient with C++. My first struggle with C++ is pointer and
reference. Althoug I think there is no different between using pointer or reference in C++, but I think each has its own place and purpose which the author of creating this C++ language has
something intended with each type.
Do you guys, experienced programmer, help to explain me what
the difference between them. When I can use Pointer and when
I can use reference. Does it difference because pointer is more efficience in execution speed than reference.
For example below that I have learn in the book but not quite clearly understanding:
Code:
class A {
              public:
                  A(); 
                  int getnum();
             private:
                  int number;
           }; 

class B  {  public:    B();
                               void setData();
                private: 
                   float data1;
             };

class C  {
                public:
                  C();
                  setAlldata();

               private:
                  A  *PtrToA;          //what the difference between these
                  B  &ReferenceToB;   //two? Why not use both pointers 
            };
Your help is grateful.
C-Dumbie