jjzjj

Declared

全部标签

c++ - 具有 move 构造函数和赋值的类的默认复制构造函数和赋值

假设我有这个类(class):classTest{public:Test();};据我所知,编译器提供了默认的复制构造函数和赋值运算符,它们将其他实例的每个成员分配给当前实例。现在我添加move构造函数和赋值:classTest{public:Test();Test(Test&&other);Test&operator=(Test&&other);};这个类是否仍然包含编译器生成的复制构造函数和赋值运算符,或者我需要实现它们?编辑。这是我的测试:classTest{public:Test(){}Test(Test&&other){}Test&operator=(Test&&other)

c++ - 错误 : no '__________' member function declared in class '_______'

我认为自己是一个相当新手的c++程序员,我以前从未遇到过这个错误。我只是想为我的函数创建一个类,但我的头文件中声明的所有std::前缀函数都没有被识别//comments//comments//comments//comments//comments//comments//comments//comments//comments//comments//comments#ifndefPERSON_H#definePERSON_H#includeclassPerson{public:Person();std::stringgetName();//returnfirstnamestd::st

java - OOP 和私有(private)字段的继承

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭6年前。Improvethisquestion在C#中,规范说:Instanceconstructors,destructors,andstaticconstructorsarenotinherited,butallothermembersare,regardlessoftheirdeclaredaccessibility(§3.5).However,dependingontheirdeclaredaccessibility,inhe

c++ - 错误 "' fdopen' was not declared"found with g++ 4 that compiled with g++3

我的代码可以用g++版本3.something愉快地编译。然后我想构建一些其他代码,其中包含C++11符号,所以我升级到g++4.7。现在我的原始代码无法构建。我收到错误:'fdopen'未在此范围内声明根据手册页,fdopen()在我包含的stdio.h中声明。我不确定它是否相关,但我在Cygwin环境中工作。我使用的g++的确切版本是Cygwin提供的版本4.7.2。自从我切换编译器后,我没有更改此代码,我可以肯定地确认它已构建并且我的测试代码运行并通过了以前的编译器。根据要求,演示问题的示例代码:#include#include#include#includeintmain(in

c++ - 错误 : definition of implicitly declared copy constructor

我目前正在处理的QtC++项目有问题。这是我要介绍的一个新部分,但我发现它有点令人困惑。我创建了一些由股票、债券和储蓄类继承的Assets类。这一切都很好。然后我创建了一个名为AssetList的类,它派生了QList,这个类是我发现问题的地方。这是我目前的代码。资源列表.h#ifndefASSET_LIST_H#defineASSET_LIST_H#include"Asset.h"#includeclassAssetList:publicQList{public:AssetList(){}~AssetList();booladdAsset(Asset*);Asset*findAsse

C++ 错误 : ‘_mm_sin_ps’ was not declared in this scope

我正在尝试对将函数应用于数组的不同方法进行基准测试。为什么是https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=3260,2124,4779,4779&cats=Trigonometry&text=_sin_mm_sin_ps在我的范围内未知,但_mm_sqrt_ps是?我如何让它为人所知?并编译无误。#include#include#include#include#include#include#include"immintrin.h"#includeintmain(){std::coutdis(-

c++ - 在 C++ 中 : why does a constructor get called when an array of objects is declared?

MyClassmc2[]={MyClass(),MyClass()};//thiscallstheconstructortwiceMyClassmc1[4];//thiscallstheconstructor4times.Why?所以,我的问题是:为什么没有初始化的对象数组声明会导致调用默认构造函数? 最佳答案 在C++中,大小为4的MyClass数组是四个实际对象。它有点像包含该类型的四个成员的结构,当然您可以使用不同的语法访问这些成员,并且存在其他技术差异。因此,定义该数组导致构建4个对象的原因(并且在大致相同的情况下)与定义该

C++ 错误 : definition of implicitly-declared

我正在用C++编写这个链表程序当我测试程序时,我得到了错误linkedlist.cpp:5:24:error:definitionofimplicitly-declared'constexprLinkedList::LinkedList()'LinkedList::LinkedList(){这是代码链表.h文件:#include"node.h"usingnamespacestd;classLinkedList{Node*head=nullptr;intlength=0;public:voidadd(int);boolremove(int);intfind(int);intcount(i

c++ - C++模板函数中,依赖函数调用为什么报 "not declared"错误?

在C++模板函数foo()中,调用::bar(TT*)在gcc4.4.3下会出现以下错误:g++-ohello.o-c-ghello.cpphello.cpp:Infunction'voidfoo(std::vector>&)':hello.cpp:8:error:'::bar'hasnotbeendeclared这是有问题的代码://hello.cpp#includetemplatevoidfoo(std::vector&vec){TT*tt;::bar(tt);vec.push_back(tt);}classBlah{};voidbar(Blah*&){}intmain(intar

c++ - 错误 C2248 : 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'

我无法理解这个错误。这个错误不在我正在调试的类中。(是吗?)错误是:c:\programfiles\microsoftvisualstudio10.0\vc\include\fstream(890):errorC2248:'std::basic_ios::basic_ios':cannotaccessprivatememberdeclaredinclass'std::basic_ios'1>with1>[1>_Elem=char,1>_Traits=std::char_traits1>]1>c:\programfiles\microsoftvisualstudio10.0\vc\inc