visual studio macro - copy a definition or declaration from/to .h to/from .cpp

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-03-31T09:08:38Z Indexed on 2010/03/31 9:13 UTC
Read the original article Hit count: 292

Filed under:
|
|

Is it possible to do a macro that copies a definition of a function to a declaration, and also the opposite? For instance

class Foo {
    Foo(int aParameter, int aDefaultParameter = 0);

    int someMethod(char aCharacter) const;
};

from the .h file would be:

Foo::Foo(int aParameter, int aDefaultParameter){
    //
}

int Foo::someMethod(char aCharacter) const {
    return 0;  
}

in the .cpp file. The opposite wouldn't work with the default value, but it would still be cool if it copied the declaration into the class in the header file. Also if it could return a default value as in someMethod (based on the return value from the declaration).

Personally I tried to do macrocoding some year ago (I think it was around 2005) but the tutorials and documentation of macros was thin (or I hadn't searched enough). I ended up going through the examples that they had in the IDE but gave up when I figured it would take too long to learn. I would however like to give it a try again. So if there are anyone with knowledge of good tutorials or documentation that aims at Visual Studio .Net (and maybe also covers the above problem) I would probably accept that as an answer as well :)

© Stack Overflow or respective owner

Related posts about c++

Related posts about visual-studio