Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. If it were not an operator

If it were not an operator

Scheduled Pinned Locked Moved Clever Code
c++databasehelpquestion
5 Posts 5 Posters 3 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.
  • R Offline
    R Offline
    Rage
    wrote on last edited by
    #1

    C++ code (simplified), VS2005:

    if (!DescribeFG(PARAM_1, &vVal, iIndex ), iType)
    {
    DisplayError();
    }

    With following prototype

    bool DescribeFG(int a, int *value, int index, int type=0);

    I do not know how the if line was understood by the compiler, but no error, no warning. Maybe the , operator ? Actually, I searched quite a while why my type was always 0 (original code is not that trivial) :~

    ~RaGE();

    I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
    Do not feed the troll ! - Common proverb

    L J T CPalliniC 4 Replies Last reply
    0
    • R Rage

      C++ code (simplified), VS2005:

      if (!DescribeFG(PARAM_1, &vVal, iIndex ), iType)
      {
      DisplayError();
      }

      With following prototype

      bool DescribeFG(int a, int *value, int index, int type=0);

      I do not know how the if line was understood by the compiler, but no error, no warning. Maybe the , operator ? Actually, I searched quite a while why my type was always 0 (original code is not that trivial) :~

      ~RaGE();

      I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
      Do not feed the troll ! - Common proverb

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      IMO there is no error, it looks like valid C++ code; it does demonstrate the "synergy of two language features" both deemed unnecessary in C#. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Happy 2008!


      1 Reply Last reply
      0
      • R Rage

        C++ code (simplified), VS2005:

        if (!DescribeFG(PARAM_1, &vVal, iIndex ), iType)
        {
        DisplayError();
        }

        With following prototype

        bool DescribeFG(int a, int *value, int index, int type=0);

        I do not know how the if line was understood by the compiler, but no error, no warning. Maybe the , operator ? Actually, I searched quite a while why my type was always 0 (original code is not that trivial) :~

        ~RaGE();

        I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
        Do not feed the troll ! - Common proverb

        J Offline
        J Offline
        Jorgen Sigvardsson
        wrote on last edited by
        #3

        If I recall correctly, the comma operator returns the last value in the list. int x = 1, 2, 3, 4, 5; will assign x the value 5.

        -- Raaaaaaaaaaaaaaaaaaaaa!

        1 Reply Last reply
        0
        • R Rage

          C++ code (simplified), VS2005:

          if (!DescribeFG(PARAM_1, &vVal, iIndex ), iType)
          {
          DisplayError();
          }

          With following prototype

          bool DescribeFG(int a, int *value, int index, int type=0);

          I do not know how the if line was understood by the compiler, but no error, no warning. Maybe the , operator ? Actually, I searched quite a while why my type was always 0 (original code is not that trivial) :~

          ~RaGE();

          I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
          Do not feed the troll ! - Common proverb

          T Offline
          T Offline
          TJoe
          wrote on last edited by
          #4

          Check out this[^]. It gives an example below. Basically, your method is called with three parameters (using the default for type). Then to evaluate the if-statement it would take the last "part". So if it was logically "!false, 1", then 1 would be evaluated as the condition for the if-statement.

          Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

          1 Reply Last reply
          0
          • R Rage

            C++ code (simplified), VS2005:

            if (!DescribeFG(PARAM_1, &vVal, iIndex ), iType)
            {
            DisplayError();
            }

            With following prototype

            bool DescribeFG(int a, int *value, int index, int type=0);

            I do not know how the if line was understood by the compiler, but no error, no warning. Maybe the , operator ? Actually, I searched quite a while why my type was always 0 (original code is not that trivial) :~

            ~RaGE();

            I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
            Do not feed the troll ! - Common proverb

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            Rage wrote:

            Maybe the , operator ?

            Of course, with default parameter complicity. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            [my articles]

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups