草庐IT

copy-protection

全部标签

c++ - Visual Studio C++ - 缺少 "Copy to Output Directory"

这个问题在这里已经有了答案:Automaticcopyfilestooutputduringapplicationbuilding(8个答案)关闭9年前。我在VisualStudio(2012)中创建了一个空的C++项目,当我在解决方案资源管理器中选择了某个文件时,在“属性”窗口中看不到“复制到输出目录”选项。为什么?

c++ - 使用哪个 : move assignment operator vs copy assignment operator

我似乎不明白为什么要使用移动赋值运算符:CLASSA&operator=(CLASSA&&other);//moveassignmentoperator结束了,复制赋值运算符:CLASSA&operator=(CLASSAother);//copyassignmentoperator移动赋值运算符仅采用r值引用,例如CLASSAa1,a2,a3;a1=a2+a3;在复制赋值运算符中,other可以是使用复制构造函数或移动构造函数的构造函数(如果other是用右值初始化的,它可以是移动构造的——如果move-constructor定义了——)。如果它是copy-constructed,我

c++ - 在派生类中强制执行 protected 构造函数

是否有任何机制允许在派生类中强制执行protected构造函数?简单的例子:templateclassFactory;classBase{templatefriendclassFactory;protected:Base();};classChild:publicBase{public:Child();//thisshouldleadtoacompiletimeerror};classFactory{Base*GetNew(){BOOST_STATIC_ASSERT(boost::is_base_of::value);Base*b=newT();b->doStuff();returnb

c++ - 指向具有 protected 继承的基类方法的指针

我有这个代码:classFoo{public:intx=4;int&operator[](size_tindex){returnx;}};classBar:protectedFoo{public:usingFoo::operator[];Bar(){x++;}};intmain(intagrc,char**argv){typedefint&(Bar::*getOp)(size_tindex);Barb;autobVal=b[4];getOpo=&Bar::operator[];autobVal2=(b.*o)(7);}但是,我不能编译它,因为errorC2247:'Foo'notacc

c++ - ‘operator=’ 的模糊重载与 c++11 std::move and copy and swap idiom

我收到以下错误:[matt~]g++-std=c++11main.cpp-DCOPY_AND_SWAP&&./a.outmain.cpp:Infunction‘intmain(int,constchar*const*)’:main.cpp:101:24:error:ambiguousoverloadfor‘operator=’in‘move=std::move((*©))’main.cpp:101:24:note:candidatesare:main.cpp:39:7:note:Test&Test::operator=(Test)main.cpp:52:7:note:Test&

c++ - 为什么 std::copy_n 采用模板参数而不是 std::size_t?

这么简单的问题。templateOutputItcopy_n(InputItfirst,Sizecount,OutputItresult);为什么std::copy_n为要复制的元素数量取一个类型,而不是简单地std::size_t?我只是想不出一个理由。templateOutputItcopy_n(InputItfirst,std::size_tcount,OutputItresult); 最佳答案 在这种情况下,推测原始原理大多是徒劳的,但对于这种设计copy_n可以用负计数调用,例如int或ptrdiff_ttype,在这种情

c++ - protected 变量命名和标准

我遇到了这个post引入可迭代队列的地方。OP在实现中使用了std::queue中名为c的protected变量。这完全有效吗?这个变量在所有实现中是否都具有相同的名称?换句话说,标准是否明确规定这个变量必须命名为c? 最佳答案 作为引用,列出了std::queue的确切定义here.所以在回答Inotherwords,doesthestandardstateclearlythatthisvariablemustbenamedc?是的,就是这种情况(其他容器适配器也类似);template>classqueue{protected:

c++ - 如何实现类似 std::copy_if 但在插入到不同容器之前应用函数的方法

完全公开,这可能是一个锤子和钉子的情况,在不需要的时候尝试使用STL算法。我在我正在使用的一些C++14代码中看到了一个重新出现的模式。我们有一个迭代的容器,如果当前元素符合某些条件,那么我们将其中一个元素字段复制到另一个容器。模式是这样的:for(autoit=std::begin(foo);it!=std::end(foo);++it){autox=it->Some_member;//Note,thecheckusuallyusesthefieldwouldaddtothenewcontainer.if(f(x)&&g(x)){bar.emplace_back(x);}}这个想法几

c++ - 基类中的公共(public) protected 数据成员?

我有一个基类和几个派生类。派生类使用一些公共(public)数据,我可以把这些公共(public)数据作为基类的保护成员吗?我知道protected成员有时会破坏封装,所以我想知道是否有什么好的方法。这是一个具体的例子:classBase{public:virtualvoidfoo()=0;voidprintData();protected:std::vectormData;}classDr1:publicBase{public:virtualvoidfoo();//couldchangemData}classDr2:publicBase{public:virtualvoidfoo()

c++ - 如何在 boost::filesystem 中使用 copy_file?

我想将一个文件从一个目录复制到另一个目录,但我的程序总是因为某些原因而中止。之前有没有人这样做过,可以告诉我哪里出了问题吗?我怎么能捕捉到copy_file抛出的异常,我查看了boost网站,但我找不到任何关于异常的相关信息。pathuser_path("C:\\MyFolder");boost::filesystem::create_directory(user_path);pathfile("C:\\Another\\file.txt");boost::filesystem::copy_file(file,user_path);谢谢, 最佳答案