Results 1 to 4 of 4

Thread: String in the method arguments

  1. #1
    Join Date
    Jul 2006
    Posts
    273

    String in the method arguments

    I guess the simplest solution is to add a "# include <string>" and remove "class std:: string, but I do not want to do to avoid multiple inclusion of file in files which will include this header and <string>. I hope that someone will be able to help me!
    Here is the code of the header of my class:
    Code:
    / / Zip.h
    
     class ifstream;
     class std:: string;
    
     using namespace std;
    
     class Zip (
         private:
             / / Ifstream * m_file;
    
         public:
             Zip (string name) 
             ~ Zip ();
     );

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: String in the method arguments

    Both include std:: string, especially since your argument fails if a file has already been included it will not be a second time in the same source file (otherwise you would have errors of multiple definitions). But good if you really want to avoid:
    Code:
     namespace std
     (
         class string;
     )
    
     class Zip
     (
     public:
    
         Zip (const std:: string & name);
     );

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: String in the method arguments

    Objective-C is a reflective, object-oriented programming language, which adds Smalltalk-style messaging to the C programming language. It is a reasonable policy for a class to skip validating arguments of private methods.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: String in the method arguments

    Code:
    # include <iosfwd>
     # include <xmemory>
    
     namespace std
     (
         template <typename, typename, typename> class basic_string;
     )
    
     class Zip
     (
     public:
    
         Zip (const std:: basic_string <char, std:: char_traits <char>, std:: allocator <char>> & name);
     );

Similar Threads

  1. Replies: 5
    Last Post: 15-12-2010, 07:18 PM
  2. How to input variable in string.find method in C++
    By Caelaan in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 10:50 PM
  3. Variable method arguments in Csharp
    By KAMANA in forum Software Development
    Replies: 3
    Last Post: 14-11-2009, 05:57 PM
  4. How to Manipulate String using PHP String Functions
    By ComPaCt in forum Software Development
    Replies: 3
    Last Post: 21-09-2009, 09:07 AM
  5. How to pass arguments to the main method
    By Wannabe in forum Software Development
    Replies: 3
    Last Post: 12-09-2009, 11:51 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,320,386.69826 seconds with 17 queries