c++学习问题汇总

docker: error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.:
出现这个说明需要登陆,
docker: Error response from daemon: open \\.\pipe\docker_engine_linux: The system cannot find the file specified.
说明需要重启

 


 

 

 命令写在后面执行后立刻退出,不写交互模式;




遇到:Errors were encountered while processing
解决方法::
cd /var/lib/dpkg
sudo mv info info.bak
sudo mkdir info
sudo apt-get update
kali是ubuntu20.04,所以ubuntu要是这个,echo deb [trusted=yes]  http://http.kali.org/kali kali-rolling main contrib non-free > /etc/apt/sources.list。
不然会出现 Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).The following packages have unmet dependencies:

apt报错源不受信任,修改apt。source为apt [trusted=yes] ....即可

void swap(int *a,int *b){
int *temp=a;
a=b;
b=temp;

}


int main() {


int x=4,y=1;
swap(x,y);//很奇怪这里不用传入指针
std::cout<< x<<std::endl;
std::cout<<y<<std::endl;

}

这样可以实现两个数字交换
void swap(int &a,int &b){
int temp=a;
a=b;
b=temp;

}


int main() {


int x=4,y=1;
swap(x,y);
std::cout<< x<<std::endl;
std::cout<<y<<std::endl;

这样也可以

 

 

*只对后面一个起作用,

 

using namespace std;
void swap(int &a,int &b){
int temp=a;
a=b;
b=temp;

}


int main() {


int x=4,y=1;
int * px=&x,*py=&y;
swap(px,py);
std::cout<< x<<std::endl;
std::cout<<y<<std::endl;

}

这样不会报错,但是不起作用
void swap(int *a,int *b){
int *temp=a;
a=b;
b=temp;

}


int main() {


int x=4,y=1;
int * px=&x,*py=&y;
swap(px,py);
std::cout<< x<<std::endl;
std::cout<<y<<std::endl;

}


即使函数换成了指针也不起作用

 

 

在没有声明的情况下不能把函数写在main后面,但是前面可以;

double sqrt(double f=33){
return f*f;
}
int main() {

std::cout<<sqrt()<<std::endl;
std::cout<<sqrt(8)<<std::endl;

}
可以把默认值直接写在函数定义;

 

 

可以把double和int混用,都可以自动转换;

 

 

 

 

未初始化的double的值很奇怪;

 

 

返回引用不能return一个表达式;

 

 如果返回常数的引用就可以;

 

 

 

 

 

 

 

 

 #include <string.h>

必须要。h文件才能使用strlen函数

 

 

 

 

 

报错,升级一下pip

Command "c:\users\administrator\appdata\local\programs\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-m_b9ifz1\\sip\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Administrator\AppData\Local\Temp\pip-record-rh4c3gr2\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Administrator\AppData\Local\Temp\pip-install-m_b9ifz1\sip\

--------------------------------------

 

libGL.so.1: cannot open shared object file: No such file or directory

pip install opencv-python-headless






 

posted on 2022-07-12 13:04  shenhshihao  阅读(27)  评论(0编辑  收藏  举报

导航