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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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
Beginners question: So if I want a private member main_cat that can be accessed by all methods, how do I initialize main_cat?
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 {
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