Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Namespace std in cmath
Forum Updated to NodeBB v4.3 + New Features

Namespace std in cmath

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simplePlan
    wrote on 19 Aug 2012, 06:07 last edited by
    #1

    I am studying C++ GUI Programming with Qt 4.1 1st edition and have a question. The plotter widgets implementation file (p.119) starts with:

    @
    #include <QtGui>
    #include <cmath>
    #include "plotter.h"
    @

    A text follows these 3 lines:

    "We include the expected header files and import all the std namespace’s
    symbols into the global namespace. This allows us to access the functions that
    are declared in <cmath> without prefixing them with std:: (for example, floor()
    instead of std::floor())."

    My personal experience is that a line similar to

    @ using namespace std; @

    is used for this purpose, which I can not find.

    So my question is: Where that namespace command is hidden? and why?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on 19 Aug 2012, 10:42 last edited by
      #2

      [quote author="simplePlan" date="1345356433"]
      So my question is: Where that namespace command is hidden? and why?
      [/quote]

      Maybe you should ask the author that? The book is not open source...

      Anyhow, yes, the line using namespace std; is needed for the described behaviour. Is it in plotter.h?

      PS: use qmath.h and then qFloor, qExp, qLn, qSin,...

      1 Reply Last reply
      0
      • S Offline
        S Offline
        simplePlan
        wrote on 19 Aug 2012, 10:57 last edited by
        #3

        It is not in 'plotter.h'. 1st edition is under Open Publication License available at http://www.qtrac.eu/marksummerfield.html (book #7).

        I also checked the find-routine in my pdf reader. No 'using namespace std' directive somewhere. I usually use the qLibraries when available, but that is an example and I want to stick to the authors code as much as i can.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on 19 Aug 2012, 11:43 last edited by
          #4

          [quote author="simplePlan" date="1345373831"]It is not in 'plotter.h'. 1st edition is under Open Publication License available at http://www.qtrac.eu/marksummerfield.html (book #7).[/quote] Nice, I didn't known that!

          [quote]I also checked the find-routine in my pdf reader. No 'using namespace std' directive somewhere.[/quote]
          I guess he then either just didn't include it in the text for brevity or just forgot it. Don't worry about it too much ;)

          1 Reply Last reply
          0
          • S Offline
            S Offline
            simplePlan
            wrote on 19 Aug 2012, 11:46 last edited by
            #5

            It is a pretty good book. Everything is explained very carefully and without any gaps. That is why I was wondering. But it is of course a minor issue.

            1 Reply Last reply
            0

            1/5

            19 Aug 2012, 06:07

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved