相关疑难解决方法(0)

什么时候应该在C++中使用类vs结构?

在什么情况下在C++中使用structvs a 更好class

c++ oop struct ooad class

895
推荐指数
15
解决办法
38万
查看次数

(C++)为什么boost作者在这里使用结构而不是类?

boost 属性树的文档中,有一个正确使用的示例,在此处或在包中给出 libs/property_tree/examples/debug_settings.cpp.

我想知道的是关于这struct debug_settings条线.为什么要把它作为结构而不是?它甚至有两个成员函数,load(...)save(...).我认为提升作者有充分的理由这样做,并且它与...效率有某种关系,即使结构和类在"技术上"相同?

从列出的版权年份,我可以猜测这可能是C++ 98,C++ 03或C++ 0x,因此使用结构而不是类的原因至少来自于前C++ 11观点.

// ----------------------------------------------------------------------------
// Copyright (C) 2002-2006 Marcin Kalicinski
//
// Distributed under the Boost Software License, Version 1.0. 
// (See accompanying file LICENSE_1_0.txt or copy at 
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see www.boost.org
// ----------------------------------------------------------------------------

//[debug_settings_includes
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <set>
#include <exception>
#include <iostream>
namespace pt = …
Run Code Online (Sandbox Code Playgroud)

c++ struct boost class data-structures

0
推荐指数
2
解决办法
312
查看次数

标签 统计

c++ ×2

class ×2

struct ×2

boost ×1

data-structures ×1

ooad ×1

oop ×1