Thread: Documentation

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    56

    Documentation

    I could be just frustrated, but for some reason after I added documentation to my program, it no longer works as it did before. I appreciate anybody taking the time to glance at it and point out what I'm sure is a totally obvious error. I am receiving 'member function redeclaration not allowed' (on my show num2 function) and 'missing function header' on my add function, as well as several related errors. I have attached my header, implementation, and main() (application) file. Thanks so much.
    P.S. Knowing that there are umpteen ways to improve this program, unfortunately I procrastinated and no longer have time to make improvements.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Search for "include guards".

    Don't comment "end for" or "end if". That's obvious. It's like 3 lines away.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    56
    A guard such as pragma once or ifndef? I will remove the end if and end for.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Yes.

    The pragma is not portable.

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    56
    I inserted this into the top of my header file and my implementation file:
    Code:
    #ifndef FATINTEGERS_H
    #define FATINTEGERS_H
    and I have a mismatching ifndef error message. How am I doing this incorrectly?

    (I should add that I've also tried only inserting it at the top of my implementation file, and in all three files, and this was the version that received the fewest errors.)

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    56
    I see that I failed to include #endif, but I when I included it, I still receive error messages identical to the first post.
    Last edited by marQade; 02-22-2008 at 04:28 PM.

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Code:
    void CFatIntegers::showNum2(char c[])
    } <--

  8. #8
    Registered User
    Join Date
    Nov 2007
    Posts
    56
    heh.

    Thank you. I appreciate that immensely.

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you look at your shownum2 function, you may notice that it somehow begins with
    Code:
    }
    Edit: slow.

  10. #10
    Registered User
    Join Date
    Nov 2007
    Posts
    56
    Still appreciated.

  11. #11
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by marQade View Post
    (I should add that I've also tried only inserting it at the top of my implementation file, and in all three files, and this was the version that received the fewest errors.)
    Include guards should be in header files, not in implementation files.

  12. #12
    Registered User
    Join Date
    Nov 2007
    Posts
    56
    OK.
    How would you have gone about formatting the numbers for display so they look nice? Such as:
    1000
    + 500
    --------
    1500

  13. #13
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Put it in a printf statement and put in some newlines (\n).

    What have you tried?

  14. #14
    Registered User
    Join Date
    Nov 2007
    Posts
    56
    I was using the iomanip library and trying to force setw() and setfill() in main(). I didn't, however, include the object name, such as:
    Code:
    cout << Centipede.setw(Centipede.getLength()+2) << Centipede.setfill(' ') << Centipede.showNum1(Centipede.num1) << endl;
    I think the compiler was having a problem with this:
    Code:
    setw(Centipede.getLength()+2) << setfill(' ') << Centipede.showNum1(Centipede.num1) << endl;

  15. #15
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So ... what did you do then?

    You didn't define your own setw, so you can't call it through your class object. Maybe this is closer:
    Code:
    cout << setw(Centipede.getLength()+2) << setfill(' ');
    Centipede.showNum1(Centipede.num1);
    cout << endl;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 06-04-2009, 09:18 AM
  2. a recent ms documentation?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 09-05-2008, 12:30 PM
  3. C++ Documentation Project (wiki, like php.net)
    By Tempest1 in forum C++ Programming
    Replies: 3
    Last Post: 09-28-2005, 02:11 PM
  4. C# Documentation
    By Mephisto_2k in forum C# Programming
    Replies: 1
    Last Post: 05-06-2004, 05:16 PM
  5. Windows.h and other documentation
    By Zlixar in forum C++ Programming
    Replies: 8
    Last Post: 03-04-2003, 05:21 PM