printing in class using one '\n'

This is a discussion on printing in class using one '\n' within the C++ Programming forums, part of the General Programming Boards category; I am pretty sure all of you are familiar with the concept of the Big4, and I have several stuffs ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    printing in class using one '\n'

    I am pretty sure all of you are familiar with the concept of the Big4, and I have several stuffs to do print in each of the constructor, assignment, destructor, and copy constructor.

    The restriction is this:

    I CAN'T use more than one newline (e.g., ƒn or std::endl) in any method

    I can have a method called print, so I am guessing print is where I will put that precious one and only '\n', my problem is that how can the method print prints different things on each of the things I want to print in each of the Big4? Any idea? Maybe overloading the Big4?

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    2,012
    Just have a print with newline function that appends a newline to a string and prints it. Everything else gets printed with flush instead of endl.

    I don't see how having only one newline effect the big 4.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    Quote Originally Posted by King Mir View Post
    Just have a print with newline function that appends a newline to a string and prints it. Everything else gets printed with flush instead of endl.

    I don't see how having only one newline effect the big 4.
    The print functions can't take any arguments so how can I deal with this

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,973
    The restriction is bizarre. Suppose that this restriction did not exist. Provide a small and simple sample program that you would thus write to meet the requirements.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 08:10 AM
  2. Defining derivated class problem
    By mikahell in forum C++ Programming
    Replies: 9
    Last Post: 08-22-2007, 02:46 PM
  3. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  4. class errors
    By romeoz in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2003, 07:57 PM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21