Wheels-Of-Fire

Forum Replies Created

Viewing 20 posts - 1,381 through 1,400 (of 1,996 total)
  • Author
    Posts
  • in reply to: Learning to program #27696
    Wheels-Of-FireWheels-Of-Fire
    Participant
      @grahamdearsley
      Forumite Points: 4

      I have submitted a new thread called C++ programming. If and when it appears I have a few things relating to classes and constructors to put in it. I fear I may be on my own here though ?

      in reply to: Learning to program #27686
      Wheels-Of-FireWheels-Of-Fire
      Participant
        @grahamdearsley
        Forumite Points: 4

        I have put a note on my memory aid sheet ?

        As im now looking at the memory management module I have noticed something else. If I use “int *Pointer = new int”  to reserve some memory then Pointer is actually an object. The memory for Pointer will be allocated from the heap instead of the stack and it will remain in use for the life of the program or until I remove it with “delete Pointer”. Don’t quote me on this though because the module on objects is between where I was and memory management and I haven’t read it yet ! They do say that creating objects and failing to delete them after use is a cause of memory leaks though.

        in reply to: Learning to program #27670
        Wheels-Of-FireWheels-Of-Fire
        Participant
          @grahamdearsley
          Forumite Points: 4

          I found the link below when I was looking up the C++ standard.

          https://isocpp.org/get-started

          I will look into some of these books later.

          in reply to: Learning to program #27669
          Wheels-Of-FireWheels-Of-Fire
          Participant
            @grahamdearsley
            Forumite Points: 4

            Oh yeh, we are also “overloading” the & operator. Int &Ref = Avariable gives us a reference to Avariable called Ref as you would expect but int *pointer = &Avariable gives us a pointer to the memory address of Avariable. And of course * and & are already used as multiply and a logical operator so it all depends on where they appear in your code. Did they have to do that ?

            in reply to: Learning to program #27668
            Wheels-Of-FireWheels-Of-Fire
            Participant
              @grahamdearsley
              Forumite Points: 4

              They also explain the gobbledy gook in the video too.

              Even though Pointer will contain the memory address of Avariable when when I use int* pointer=&Avariable, Pointer must still be the same data type as Avariable because it must be capable of holding its value as well. Pick the bones out of that if you will ?

              in reply to: Learning to program #27667
              Wheels-Of-FireWheels-Of-Fire
              Participant
                @grahamdearsley
                Forumite Points: 4

                Ah. Reading ahead again they have their explination in print. We are “overloading” the use of the * operator, we are using it both to declare the use of a pointer (int *Pointer=&Avariable) and to dereference a variable (cout << *Pointer in my example). If I just want to reserve some memory for a pointer of type int then apparently I must use the NEW key word.

                Int *Pointer = new int

                This is all in the memory management chapter, about 3 ahead of where I am !

                in reply to: Learning to program #27666
                Wheels-Of-FireWheels-Of-Fire
                Participant
                  @grahamdearsley
                  Forumite Points: 4

                  Avariable is declared and initialised with a value of 3 at the beginning of the program so it has an address in memory. Int* Pointer=&Avariable really does put the memory address of Avariable into Pointer even though it is 4 bytes long. It does not matter if I put the space before or after the * either.

                  in reply to: Learning to program #27665
                  Wheels-Of-FireWheels-Of-Fire
                  Participant
                    @grahamdearsley
                    Forumite Points: 4

                    Another thing that was shown in a video clip, but not actually mentioned, relates to splitting your function definitions  into a separate cpp ( only just realised that cpp stands for C plus plus ?) file. They say you should create a new header file with the function declaration in it, fine. They say that your new cpp file with the function definition in it and your main cpp must include your header file, fine. They do not say that EVERY cpp file must include the “Pre Compiled Header”.  Bloody thing would not build ?

                    in reply to: Learning to program #27663
                    Wheels-Of-FireWheels-Of-Fire
                    Participant
                      @grahamdearsley
                      Forumite Points: 4

                      double Pointer=&Avariable won’t work either, another type mismatch error.

                      in reply to: Learning to program #27660
                      Wheels-Of-FireWheels-Of-Fire
                      Participant
                        @grahamdearsley
                        Forumite Points: 4

                        You would think so but it works in Visual Studio and it is the way the Microsoft course told me to do it. If I remove the * dereference from Pointer then I get a type mismatch error. The address in Pointer is indeed a four byte value. They give some reason about why this works but its in a video clip and I have played it back several times without being any the wiser.

                        I wrote the code myself in Visual Studio and pasted it here so you can paste it back and try it if you like ?

                        in reply to: Learning to program #27656
                        Wheels-Of-FireWheels-Of-Fire
                        Participant
                          @grahamdearsley
                          Forumite Points: 4

                          One error is that the output is 3, memory address, 3,3,4.

                          I could also have just used Ref++ instead of Ref=Ref++, a hangover from my BASIC ways ?

                          in reply to: Straight to Winter, no Autumn! #27653
                          Wheels-Of-FireWheels-Of-Fire
                          Participant
                            @grahamdearsley
                            Forumite Points: 4

                            A crisp and sunny 10° in Wembley at the moment.

                            in reply to: Learning to program #27648
                            Wheels-Of-FireWheels-Of-Fire
                            Participant
                              @grahamdearsley
                              Forumite Points: 4

                              I am just about to print out the following and add it to my C++ Course folder as a memory aid. If anyone can spot any errors please let me know.

                              #include “pch.h”

                              #include <iostream>

                              using namespace std;

                              int main()

                              {

                              // Another way to assign a variable

                              int Avariable{ 3 };

                              cout << Avariable << endl;

                              // A pointer to a memory address

                              int *Pointer = &Avariable;

                              cout << Pointer << endl;

                              // DeReff a Pointer

                              cout << *Pointer << endl;

                              // Reference or alias a variable

                              int &Ref = Avariable;

                              cout << Ref << endl;

                              Ref = Ref++;

                              cout << Avariable << endl;

                               

                              return (0);

                              }

                              The output is 3, memory address, 3, 4.

                               

                              in reply to: Brexit now = CETA +/-? #27582
                              Wheels-Of-FireWheels-Of-Fire
                              Participant
                                @grahamdearsley
                                Forumite Points: 4

                                So many jokes I could make about the EU having 1 mind here..

                                But I won’t bother ?

                                in reply to: Brexit now = CETA +/-? #27565
                                Wheels-Of-FireWheels-Of-Fire
                                Participant
                                  @grahamdearsley
                                  Forumite Points: 4

                                  There are actually two “its” . I did make the first one clear. The EU institution HATES us. They hate our ways they hate our history they hate any success we may have and most of all they hate the fact that they need our money ! They keep telling us we need THEM while all the while they are bleeding US dry. Not all of us are happy for this to continue and that brings me to the second “it”. We had a “Peoples” vote for a change and the result MUST stand. The “elected dictatorship” as Ed puts it must do as they were told for a change.

                                  in reply to: Learning to program #27548
                                  Wheels-Of-FireWheels-Of-Fire
                                  Participant
                                    @grahamdearsley
                                    Forumite Points: 4

                                    They actually did a fair job with arrays and pointers. First they did data types for variables and THEN pointers and THEN pointers into arrays. Even there though they tended to assume that I am already handy with Visual Studio (I am not?).

                                    I originally taught myself C out of a book on my Atari ST and I dont remember having to read ahead just to understand the topic being talked about, refer back plenty but not forward. I think it may have something to do Hyperlink style of writing used on the web these days. This style just does not translate well into a book or video clip.

                                    in reply to: Redundancy/Pensions/Tax #27544
                                    Wheels-Of-FireWheels-Of-Fire
                                    Participant
                                      @grahamdearsley
                                      Forumite Points: 4

                                      Who do you trust as a financial advisor ? One school of thought is to get an independent FA because they can advise you on products from any company. On the other hand they are just as likely to sell you something that earns them the most commission. The Pru used to offer some good free advice on such things and you dont have to take it.

                                      in reply to: Learning to program #27535
                                      Wheels-Of-FireWheels-Of-Fire
                                      Participant
                                        @grahamdearsley
                                        Forumite Points: 4

                                        I ment should have been told in the introduction course.

                                        in reply to: Learning to program #27524
                                        Wheels-Of-FireWheels-Of-Fire
                                        Participant
                                          @grahamdearsley
                                          Forumite Points: 4

                                          Is higgledy piggledy the new method of teaching or is it just a Microsoft thing ? I first noticed it in the Microsoft press Windows Internals books. These books would keep doing things like this.

                                          We will now cover “something”. In order to understand “something” you must first understand “something else” that we will cover in a later chapter.

                                          They then go on as if you already know what “something else” is. You end up having to read through the whole book four or five times, picking up what you can each time.

                                          Now I am finding the same thing on the Microsoft C++ course on edX. At the end of the introduction course, past the final self test, they tacked on a video about C++ classes. The video said don’t worry if you don’t get everything going on here because it will all be explained in the intermediate course. The intermediate course starts off with some things about headers in Visual Studio I should have been told in the intermediate course and then moves on with “As we learnt about classes in part one” !

                                           

                                          in reply to: Learning to program #27523
                                          Wheels-Of-FireWheels-Of-Fire
                                          Participant
                                            @grahamdearsley
                                            Forumite Points: 4

                                            Quite likely, and I have now also read that it would be difficult to do consistently on larger projects, especially those involving collaboration.

                                          Viewing 20 posts - 1,381 through 1,400 (of 1,996 total)