![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++入门
georgelonely
努力
展开
-
c++调用构造函数时数据类型不匹配的几种情况
#include<iostream> using namespace std; class A{ public : A(int i){ cout<<"double"; } A(float i){ cout<<"float"; } // A():A(5.0){ y=2;} // float x=1,y=2; }; int main...原创 2019-05-15 20:41:33 · 949 阅读 · 0 评论 -
C++显示调用析构函数会出现什么情况?
看代码 #include<iostream> using namespace std; class a{ public: int x=20; ~a(){ cout<<"调用析构函数"; } }; int main(){ a k; k.~a(); cout<<k.x<<endl; } 输出结果: 调用析构函数2...原创 2019-05-16 10:36:36 · 1100 阅读 · 0 评论 -
c++ 可见性
种类 可见性 public 公有 protect 允许在类内及该类的派生类(子类)中使用,不允许使用对象访问。 private 允许在类内使用,不允许对象访问。 ...原创 2019-05-16 21:57:03 · 898 阅读 · 0 评论