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. vc++ 6--add member function, using macros

vc++ 6--add member function, using macros

Scheduled Pinned Locked Moved C / C++ / MFC
c++questiontoolshelplearning
6 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.
  • 7 Offline
    7 Offline
    7stud
    wrote on last edited by
    #1

    1)On p.370 of Ivor Horton's Beginning Visual C++ 6, it says you can add operator functions to the class by clicking on the down arrow to the right of the Wizard bar and selecting Add Member Function. I tried that, and after I entered the first operator function, the declaration was added to the class in the .h file, and a skeleton function definition was added to the .cpp file. So far, so good. Then, when I tried to add a second operator function, it only added a skeleton function definition to the .cpp file and would not add the declaration to the .h file. How can I get it to do that? 2)A little later in the chapter on p. 374, it says that instead of typing in preprocessor functions into the header file, you can use a macro in VC++6 that will do it for you. The book says to click on Tools/Macro and select OneTimeInclude from the macros list in the Macro dialog box that pops up. My macros list is blank in the dialog box. I tried typing in OneTimeInclude, but I got an error that said I had to choose a macro from the list--what list, it's blank?!

    C 1 Reply Last reply
    0
    • 7 7stud

      1)On p.370 of Ivor Horton's Beginning Visual C++ 6, it says you can add operator functions to the class by clicking on the down arrow to the right of the Wizard bar and selecting Add Member Function. I tried that, and after I entered the first operator function, the declaration was added to the class in the .h file, and a skeleton function definition was added to the .cpp file. So far, so good. Then, when I tried to add a second operator function, it only added a skeleton function definition to the .cpp file and would not add the declaration to the .h file. How can I get it to do that? 2)A little later in the chapter on p. 374, it says that instead of typing in preprocessor functions into the header file, you can use a macro in VC++6 that will do it for you. The book says to click on Tools/Macro and select OneTimeInclude from the macros list in the Macro dialog box that pops up. My macros list is blank in the dialog box. I tried typing in OneTimeInclude, but I got an error that said I had to choose a macro from the list--what list, it's blank?!

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

      1. Burn the wizard, learn to do it yourself. You obviously know where things need to go, so put them there. Wizards are good to help you get started, but you should always move beyond them and learn to use the language more than the IDE. 2. I've never used this because macros are evil. The one time include should be present anyhow, when the class is generated by the wizard. Apart from this you should not use macros unless you really need them, i.e. where a const variable or inline function will not do the trick. In the real world, that generally means when you're writing debugging/tracing tools. Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma

      N 7 2 Replies Last reply
      0
      • C Christian Graus

        1. Burn the wizard, learn to do it yourself. You obviously know where things need to go, so put them there. Wizards are good to help you get started, but you should always move beyond them and learn to use the language more than the IDE. 2. I've never used this because macros are evil. The one time include should be present anyhow, when the class is generated by the wizard. Apart from this you should not use macros unless you really need them, i.e. where a const variable or inline function will not do the trick. In the real world, that generally means when you're writing debugging/tracing tools. Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        Christian Graus wrote: NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma Respected sir, I found your signature interesting and to learn more about what it meant, I clicked on the Vinod Sharma HTTP link, but I only got a page that says this.

        The page you requested cannot be found.
        Click here to go to the CodeProject home page,
        or click here to return to the previous page.

        Do I have to reinstall Internet Explorer to get the correct page? I am using XP Home by the way with a black mouse pad! You never know if it is the environment that is causing the error. Awaiting your kind response please, Respects, Nish :rolleyes:


        Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

        1 Reply Last reply
        0
        • C Christian Graus

          1. Burn the wizard, learn to do it yourself. You obviously know where things need to go, so put them there. Wizards are good to help you get started, but you should always move beyond them and learn to use the language more than the IDE. 2. I've never used this because macros are evil. The one time include should be present anyhow, when the class is generated by the wizard. Apart from this you should not use macros unless you really need them, i.e. where a const variable or inline function will not do the trick. In the real world, that generally means when you're writing debugging/tracing tools. Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma

          7 Offline
          7 Offline
          7stud
          wrote on last edited by
          #4

          Thanks for responding. 1)I would rather save myself the hassle of having to type the function header twice: once in the class definition and once in the function definition. For some reason the wizard has a problem with operator functions in the class definition: it doesn't seem to recognize that operator+() is different than operator*(), but it does in the class implementation file because it adds a new skeleton function definition there. 2)I don't really understand your explanation here. As far as I can determine, the macro I'm supposed to run adds the preprocessor directives to my .h file--not a macro--so that once again it will save me the hassle of typing them in myself. Do you use VC++ 6? If so, could you click on Tools/Macro and tell me if OneTimeInclude is in the list of macros? Thanks

          C 1 Reply Last reply
          0
          • 7 7stud

            Thanks for responding. 1)I would rather save myself the hassle of having to type the function header twice: once in the class definition and once in the function definition. For some reason the wizard has a problem with operator functions in the class definition: it doesn't seem to recognize that operator+() is different than operator*(), but it does in the class implementation file because it adds a new skeleton function definition there. 2)I don't really understand your explanation here. As far as I can determine, the macro I'm supposed to run adds the preprocessor directives to my .h file--not a macro--so that once again it will save me the hassle of typing them in myself. Do you use VC++ 6? If so, could you click on Tools/Macro and tell me if OneTimeInclude is in the list of macros? Thanks

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

            7stud wrote: I would rather save myself the hassle of having to type the function header twice CTRL-V = paste, CTRL-C = copy. 7stud wrote: For some reason the wizard has a problem wizards suck, that's only one reason to move past using them. Any MS wizard I have used has failed at times, and that's when I've been mighty glad I don't need them to know how to fix/add stuff. 7stud wrote: As far as I can determine, the macro I'm supposed to run adds the preprocessor directives to my .h file I've never, ever heard of this. If I add a class using the wizard, I get an include guard, if I write my own, I write my own include guard, again relying on copy/paste. 7stud wrote: If so, could you click on Tools/Macro and tell me if OneTimeInclude is in the list of macros? It's empty, as I would expect. I'd expect this to include macros as in UI sequences I recorded, not macros as in #define BLAH blah Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma

            7 1 Reply Last reply
            0
            • C Christian Graus

              7stud wrote: I would rather save myself the hassle of having to type the function header twice CTRL-V = paste, CTRL-C = copy. 7stud wrote: For some reason the wizard has a problem wizards suck, that's only one reason to move past using them. Any MS wizard I have used has failed at times, and that's when I've been mighty glad I don't need them to know how to fix/add stuff. 7stud wrote: As far as I can determine, the macro I'm supposed to run adds the preprocessor directives to my .h file I've never, ever heard of this. If I add a class using the wizard, I get an include guard, if I write my own, I write my own include guard, again relying on copy/paste. 7stud wrote: If so, could you click on Tools/Macro and tell me if OneTimeInclude is in the list of macros? It's empty, as I would expect. I'd expect this to include macros as in UI sequences I recorded, not macros as in #define BLAH blah Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma

              7 Offline
              7 Offline
              7stud
              wrote on last edited by
              #6

              Christian Graus wrote: If so, could you click on Tools/Macro and tell me if OneTimeInclude is in the list of macros? It's empty, as I would expect. I'd expect this to include macros as in UI sequences I recorded, not macros as in #define BLAH blah After several days of messing around with this macro deal, I finally figured it out. If you're interested, with no files open in VC++6 click on Tools\Macro, then click on Options/Loaded Files, and the "Add ins and Macro files" tab should be selected(if not select it). There is a macro called Sample which you should enable by clicking on the check box. Then click on Close. From then on when the Macro dialog box appears after you click on Tools\Macros, you can select Sample as the "Macro file:", and from the list you can choose OneTimeInclude. When you click on Run, the macro will add your preprocessor directives for you. There are also other sample macros that are probably useful. Thanks for your help.

              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