Viewing 20 posts - 1 through 20 (of 259 total)
  • Author
    Posts
  • #27773
    Wheels-Of-FireWheels-Of-Fire
    Participant
      @grahamdearsley
      Forumite Points: 4

      <p style=”text-align: right;”>Can we put this topic up please boss. In tech ?</p>

      #28231
      Wheels-Of-FireWheels-Of-Fire
      Participant
        @grahamdearsley
        Forumite Points: 4

        edX made a mistake in their very first attempt at showing how to split a class into sepperate declaration header and definition cpp files. The header called Math.h was:

        #pragma once

        static class Math

        {

        public:

        Static int maths::pow(int base, int exp);

        };

        And the cpp definition was:

        #include “pch.”

        #include “math.h”

        Int Math::pow(int base, int exp)

        {

        int result = 1

        for (int 1=0; i<exp; i++)

        {

        result=result*base;

        }

        return result;

        The error message was ” qualified name not allowed in member declaration” can anyone spot it ? Took me 20 min.

         

        #28232
        Wheels-Of-FireWheels-Of-Fire
        Participant
          @grahamdearsley
          Forumite Points: 4

          edX made a mistake in their very first attempt at showing how to split a class into sepperate declaration header and definition cpp files. The header called Math.h was:

          #pragma once

          static class Math

          {

          public:

          Static int Math::pow(int base, int exp);

          };

          And the cpp definition was:

          #include “pch.”

          #include “math.h”

          Int Math::pow(int base, int exp)

          {

          int result = 1

          for (int 1=0; i<exp; i++)

          {

          result=result*base;

          }

          return result;

          The error message was ” qualified name not allowed in member declaration” can anyone spot it ? Took me 20 min.

           

          #28233
          Wheels-Of-FireWheels-Of-Fire
          Participant
            @grahamdearsley
            Forumite Points: 4

            Oops posted that twice. The second one is correct ?

            #28260
            Wheels-Of-FireWheels-Of-Fire
            Participant
              @grahamdearsley
              Forumite Points: 4

              Well we seem to have an extra “Math::” scope qualfier in the header file, as we are already in the “Math” class declaration this is not required or legal.

              #29484
              Wheels-Of-FireWheels-Of-Fire
              Participant
                @grahamdearsley
                Forumite Points: 4

                Hmm. I got the book ” A Tour of C++” for Christmas and very good it is too. The thing is though I have only read a little bit and already it is telling me that things I have been learning are going to be out of date.

                I am now fairly confident with splitting my classes into separate declaration and definition files and then using an #include<header.h> in my main .cpp but the book says that with the coming of C++20 I should forget about that and start using module, export module and import instead !

                #29489
                Ed PEd P
                Participant
                  @edps
                  Forumite Points: 39

                  Unless you have a professional need to keep up with the twists and turns of C++’s evolution, my advice would be to stick to the release you started with, as whatever the new flavour of the month it will be backwards compatible. Take some pleasure in knowing you do not have the problems of the Pythonic crowd where the change from 2.7 to 3.0 was totally incompatible, and they are still releasing point releases that are not completely compatible with earlier ones!

                  Imo the main value in learning C++ is the insight that the Object structure gives to program design.

                  #29491
                  SpedleySpedley
                  Participant
                    @spedley
                    Forumite Points: 2

                    I can imagine Ed P.  I’ve just started using Python (3 obviously) and the amount online help has already shifted to 3 with most of 2 being outdated.  It does seem to have been quite a change!

                    i7 4790s / 8GB / 480GB SSD / GTX 980 / 34" UltraWide : i3 4170 / 8GB / 480GB SSD / GTX 770 / 24" Samsung : i3 4130 / 8GB / 500GB Spinner / GTX 1050 / 23" Acer : Q9550 / 8GB / 1TB Spinner / GTX 580 / 22" Acer : i7 720QM / 8GB / 1TB+2TB+500GB Spinners (server) : i5 4570 / 8GB / 60GB SSD / 1TB / GeForce 210 / 22" Dell It's getting warm in here!

                    #29493
                    Wheels-Of-FireWheels-Of-Fire
                    Participant
                      @grahamdearsley
                      Forumite Points: 4

                      Ed is right with C++. It stays compatible. Your sourse code from years ago will still most likely compile and run. I am going to look into modules though because the author of C++ says I should ?

                      #29518
                      Ed PEd P
                      Participant
                        @edps
                        Forumite Points: 39

                        The object part of C++ i.e. C++ without the training wheels! (joke)

                        link

                        Could sometimes be useful as C++ for areas where you need to have very tight code coupled with more generalised UI access code in one portable module and no run-time overhead.

                        Sometimes I think C++ adds complexity rather than maintainability.

                        #29557
                        Wheels-Of-FireWheels-Of-Fire
                        Participant
                          @grahamdearsley
                          Forumite Points: 4

                          I have found a couple of generic graphics library’s for C++ that act as a sort of abstraction for the underlying OS. These allow you to open windows, draw lines, circles and such like. As long as you can include a version of the library on your particular OS then the source code should be portable.

                          #29603
                          Wheels-Of-FireWheels-Of-Fire
                          Participant
                            @grahamdearsley
                            Forumite Points: 4

                            Well fancy that.

                            I just found out that even the most recent versions of C++ still support the “goto” keyword.

                            Now I can make my programs even more spaghetti like than usual ?

                            #29604
                            Wheels-Of-FireWheels-Of-Fire
                            Participant
                              @grahamdearsley
                              Forumite Points: 4

                              How about.

                              int main()

                              { label:;

                              cout << “Hello “;

                              goto label;

                              }

                              ?

                               

                               

                              #29608
                              Ed PEd P
                              Participant
                                @edps
                                Forumite Points: 39

                                Very rarely a GOTO will save a mountain of recursive subroutine exits. Even the most pedantic haters of spaghetti code will agree that a simple GOTO is actually more clear and better code in such rare cases.

                                #29613
                                Wheels-Of-FireWheels-Of-Fire
                                Participant
                                  @grahamdearsley
                                  Forumite Points: 4

                                  Atari BASIC provides the POP command for just that purpose. If you exit a loop before its completion using a goto then you should also use POP to clear the iterator off the stack.

                                  #29631
                                  Ed PEd P
                                  Participant
                                    @edps
                                    Forumite Points: 39

                                    I said subroutines, but it would probably have been better to pick out nested ‘if then’ loops as an example, as you are correct, just exiting nested subroutines leaves a stack clean-up issue.

                                    #31104
                                    Wheels-Of-FireWheels-Of-Fire
                                    Participant
                                      @grahamdearsley
                                      Forumite Points: 4

                                      I am going to swallow my pride and get Bjarne Stroustrup’s book on programming practice using C++. Why ? Because much of the C++ stl library is written in C++ and I need to know how to modify it !

                                      #31106
                                      Ed PEd P
                                      Participant
                                        @edps
                                        Forumite Points: 39

                                        I am going to swallow my pride and get Bjarne Stroustrup’s book on programming practice using C++. Why ? Because much of the C++ stl library is written in C++ and I need to know how to modify it !

                                        Why?

                                        You may want to look at what Stroustrop says on it: link

                                        #31107
                                        Wheels-Of-FireWheels-Of-Fire
                                        Participant
                                          @grahamdearsley
                                          Forumite Points: 4

                                          http://www.stroustrup.com/programming.html

                                          I also like the way he thinks Ed

                                          Have a look at the preface and other links.

                                          #31108
                                          Wheels-Of-FireWheels-Of-Fire
                                          Participant
                                            @grahamdearsley
                                            Forumite Points: 4

                                            No chance of me re wrighting an STL anytime soon but I can add my own operators with a new constructor. I think ?

                                          Viewing 20 posts - 1 through 20 (of 259 total)
                                          • You must be logged in to reply to this topic.