标签:blog io os ar sp 2014 art on log
主程序
/*将抽象部分与实现部分分离,使它们都可以独立的变化*/ #include "bridge.h" int main() { cout <<"main start" <<endl; sample smp; smp.display(); cout <<"main end" <<endl; //sample::bridge bri; //error: ‘class sample::bridge’ is private return 0; }
#include <boost/smart_ptr.hpp> #include <iostream> using namespace boost; using namespace std; class sample { private: class bridge; shared_ptr<bridge> bptr; public: sample(); void display(); }; class sample::bridge { public: void display(); };
#include "bridge.h" sample::sample() { bptr = make_shared<bridge>(); } void sample::display() { bptr->display(); } void sample::bridge::display() { cout << "bridge display!"<<endl; }
.SUFFIXES:.h .c .cpp .o CC=$(CXX) $(CXX_FLAG) RM = rm SRCS = bridge.cpp main.cpp PROGRAM = bridge OBJS=$(SRCS:.cpp=.o) INC_PATH = -I$(BOOST_INCLUDE) LIB_PATH = -L$(BOOST_LIB) LIBS = -lboost_date_time $(PROGRAM):$(OBJS) $(CC) $? $(LIB_PATH) $(LIBS) -o $@ $(OBJS):$(SRCS) $(CC) $(CPPFLAGS) -c $(SRCS) $(INC_PATH) .PHONY:clean clean: $(RM) $(PROGRAM) $(OBJS)
标签:blog io os ar sp 2014 art on log
原文地址:http://blog.csdn.net/leeboy_wang/article/details/39990479