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. The Weird and The Wonderful
  4. duplicate variable names seperated by scope

duplicate variable names seperated by scope

Scheduled Pinned Locked Moved The Weird and The Wonderful
comregexhelp
2 Posts 2 Posters 18 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.
  • J Offline
    J Offline
    Jason De Arte
    wrote on last edited by
    #1

    I was once maintaining some odd looking code that had the (no joke) the following pattern: int variable; class CSomething { public:  int variable;   void Func(int variable) {   // do something   {     int variable;     // do something where the bug I was trouble shooting was located   }  }; }; Count them: FOUR declarations of the same variable name (and type) in the same file! 1) In the global scope 2) As a member var 3) as a function parameter 4) declared IN SIDE the function that has the identical named param Yes, it was legal - but it didn't make it right.

    [ Jason De Arte | Toy Maker | 1001010.com ]

    B 1 Reply Last reply
    0
    • J Jason De Arte

      I was once maintaining some odd looking code that had the (no joke) the following pattern: int variable; class CSomething { public:  int variable;   void Func(int variable) {   // do something   {     int variable;     // do something where the bug I was trouble shooting was located   }  }; }; Count them: FOUR declarations of the same variable name (and type) in the same file! 1) In the global scope 2) As a member var 3) as a function parameter 4) declared IN SIDE the function that has the identical named param Yes, it was legal - but it didn't make it right.

      [ Jason De Arte | Toy Maker | 1001010.com ]

      B Offline
      B Offline
      bluesboy84
      wrote on last edited by
      #2

      Makes me remind of the last programming exams i took... They make you go insane with a snippet 10 times difficult than the above, then they ask you "WTF does var on line x refer to, which is its value?" Someone just never learns ;)

      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