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
这样可以实现两个数字交换
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 阅读(34) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」