文章分类 -  c++

摘要:一个简易版本,有很多的bug以及优化的地方 template<class T> class Vector { public: Vector() :size(0), capacity(10) { p = new T[capacity]; } Vector(int size, T& x) :size(s 阅读全文
posted @ 2025-10-08 18:47 gan_coder 阅读(5) 评论(0) 推荐(0)
摘要:发现写了一年c++,还是有很多关于类的知识不熟悉。 开一篇blog来总结遇到得错误 调用无参构造函数 比如调用无参构造函数时, 应该 A a; 而不是这样 A a(); 第二种写法相当于定义了一个返回A类型的函数 这也解释了为什么下面这段代码会编译错误 #include<cstdio> #inclu 阅读全文
posted @ 2023-09-03 09:17 gan_coder 阅读(21) 评论(0) 推荐(0)