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. General Programming
  3. C / C++ / MFC
  4. backslash

backslash

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 Posts 3 Posters 0 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.
  • N Offline
    N Offline
    NicholasCougar
    wrote on last edited by
    #1

    Hi, I encounter such a problem as the usage of backslash '\' , follows are details

    syntax
    textline\

    For example,

    #define DECLARE_DYNAMIC(class_name)\
    public: \
    static CRuntimeClass class##class_name; \
    virtual CRuntimeClass *GetRuntimeClass() const;

    What does '\' mean here? Thank you in advance. Best regard. One concrete prolem is worth a thousand unapplied abstractions.

    C P 2 Replies Last reply
    0
    • N NicholasCougar

      Hi, I encounter such a problem as the usage of backslash '\' , follows are details

      syntax
      textline\

      For example,

      #define DECLARE_DYNAMIC(class_name)\
      public: \
      static CRuntimeClass class##class_name; \
      virtual CRuntimeClass *GetRuntimeClass() const;

      What does '\' mean here? Thank you in advance. Best regard. One concrete prolem is worth a thousand unapplied abstractions.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      A macro is a horrible construct left over from C. It basically means that where-ever MFC puts DECLARE_DYNAMIC(class_name), the code given is expanded out 'in place' by the preprocessor, with class_name replaced by whatever was passed in. To see why this is bad, consider a macro that takes a variable, x, and uses it three times in the expanded function, and what would happen if ++i was passed in as the value.... But in answer to your question, it allows the macro to be defined over multiple lines. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile. - Jamie Hale, 17/4/2002

      1 Reply Last reply
      0
      • N NicholasCougar

        Hi, I encounter such a problem as the usage of backslash '\' , follows are details

        syntax
        textline\

        For example,

        #define DECLARE_DYNAMIC(class_name)\
        public: \
        static CRuntimeClass class##class_name; \
        virtual CRuntimeClass *GetRuntimeClass() const;

        What does '\' mean here? Thank you in advance. Best regard. One concrete prolem is worth a thousand unapplied abstractions.

        P Offline
        P Offline
        Paul M Watt
        wrote on last edited by
        #3

        It basically allows the statement from the previous line to continue to the next line. Mainly they are used in macros like Christian Graus has explained above. There are not very many other useful uses for this operator.


        Build a man a fire, and he will be warm for a day
        Light a man on fire, and he will be warm for the rest of his life!

        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