/*
* @Author: lenovouser
* @Date: 2020-09-06 15:59:07
* @Last Modified by: lenovouser
* @Last Modified time: 2020-09-06 16:00:25
*/
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include<ctime>
#include<vector>
#include <cstring>
using namespace std;
class A
{
public:
int a=0;
A(){a=5;cout<<"A";}
};
class B:public A
{
public:
B(){a++;cout<<"B";}
};
int main(int argc, char const *argv[])
{
/* code */
B b;
cout<<b.a;
// char a[]={'1','0'};
// cout<<sizeof(a)<<strlen(a);
return 0;
}
子类构造函数会调用父类构造函数。
const int i=100;
int *j=const_cast<int*>(&i);
*j=200;
cout<<i<<endl<<*j<<endl<<&i<<endl<<j;
- 以下三条输出语句分别输出什么?
char str1[] = “abc”;
char str2[] = “abc”;
const char str3[] = “abc”;
const char str4[] = “abc”;
const char* str5 = “abc”;
const char* str6 = “abc”;
cout << boolalpha << ( str1str2 ) << endl; // 输出什么?false
cout << boolalpha << ( str3str4 ) << endl; // 输出什么?false
cout << boolalpha << ( str5==str6 ) << endl; // 输出什么?true
char * const p; //常指针或者指针常量,p的值不可以修改
char const * p;//指向常量的指针或常量指针,指向的常量值不可以改
const char *p; //同char const *p
str1,str2,str3,str4是数组变量,它们有各自的内存空间;
而str5,str6是指针,它们指向相同的常量区域
#include
using namespace std;
int main()
{
bool b=true;
cout <<“b=”<< b << endl;
b =false;
cout <<“b=”<< b << endl;
cout <<“b=”<< boolalpha << b << endl;
cout << b << endl;
bool a =true;
cout <<"a = "<< a << endl;
}
输出结果:
b=1
b=0
b=false
0
a =1
/*
* @Author: lenovouser
* @Date: 2020-09-06 15:59:07
* @Last Modified by: lenovouser
* @Last Modified time: 2020-09-06 16:00:25
*/
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include<ctime>
#include<vector>
#include <cstring>
using namespace std;
class A
{
public:
int a=0;
A(){a=5;cout<<"A";}
};
class B:public A
{
public:
B(){a++;cout<<"B";}
};
int main(int argc, char const *argv[])
{
/* code */
// B b;
// cout<<b.a;
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
char a[]={'a','b','c'};
// cout << boolalpha << ( str1==str2 ) << endl; // 输出什么?fals
cout<<sizeof(str1)<<sizeof(a)<<endl<<strlen(str1)<<strlen(a)<<endl;
cout<<sizeof(str5)<<strlen(str5);
//
// char a[]={'1','0'};
// cout<<sizeof(a)<<strlen(a);
return 0;
}
strlen(a)居然是6.
/*
* @Author: lenovouser
* @Date: 2020-09-06 15:59:07
* @Last Modified by: lenovouser
* @Last Modified time: 2020-09-06 16:00:25
*/
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include<ctime>
#include<vector>
#include <cstring>
using namespace std;
class A
{
public:
int a=0;
A(){a=5;cout<<"A";}
};
class B:public A
{
public:
B(){a++;cout<<"B";}
};
struct T
{
uint8_t a;
uint16_t b;
uint32_t c;
};
int main(int argc, char const *argv[])
{
/* code */
T t;
cout<<sizeof(t.a)<<sizeof(t.b)<<sizeof(t.c)<<sizeof(t);
// B b;
// cout<<b.a;
}
大光圈,浅景深。长焦距浅景深。
f/n,n越大,光圈越小。
n=焦距/光圈
定焦是焦距固定,可以对焦。
色温谱,从红到蓝。
多线程。