Menu

Category copy constructor

Help
2003-01-11
2003-03-05
  • Sergey Matveychuk

    I cant to build the example from http://soldc.sun.com/articles/logging.html/
    because of error on this line:
    log4cpp::Category main_cat =
                     log4cpp::Category::getInstance("main_cat");

    I see Category copy constructor is protected.
    How can I change this line to work?

     
    • Bastiaan Bakker

      Bastiaan Bakker - 2003-01-13

      Copy construction is explicitly not alllowed for Category, the line should use a reference instead:

      log4cpp::Category& main_cat =
      log4cpp::Category::getInstance("main_cat");

      Bastiaan

       
    • Håkan Jonsson

      Håkan Jonsson - 2003-03-05

      Beginners question: So if I want a private member main_cat that can be accessed by all methods, how do I initialize main_cat?

       
    • Bastiaan Bakker

      Bastiaan Bakker - 2003-03-05

      You can't have a member instance of Category, only a member reference to Category. You can initialize it like any other reference member of a class:

      class MyClass {

       
    • Bastiaan Bakker

      Bastiaan Bakker - 2003-03-05

      You can't have a member instance of Category, only a member reference to Category. You can initialize it like any other reference member of a class:

      class MyClass {
         public:
         MyClass() :
            main_cat(log4cpp::Category::getInstance("main_cat")) {
               // constructor code
         };

         private:
         log4cpp::Category& main_cat;
      };

      Bastiaan

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.