class question

This is a discussion on class question within the C++ Programming forums, part of the General Programming Boards category; Hello.. I have a class Code: class someclass { public: someclass (string d = "", string p = "") : ...

  1. #1
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630

    class question

    Hello..

    I have a class

    Code:
    class someclass {
    public:
    	someclass (string d = "", string p = "") : domain(d) { priority = p; }
    	string domain;
    	string priority;
    };
    How should I pass p as priority to the class the same way as domain (d) not inside the { } ?

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,325
    Add a comma, then do the same thing as you did with domain. The initializer list is a comma separated list of initializations.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  2. Replies: 8
    Last Post: 10-02-2005, 12:27 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. question about DLL's and class functions
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 02-25-2003, 05:08 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM

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