摘要: 运算符重载本质 重新定义运算符的操作,返回自定义的结果。 对于A operator sign (B res1 , C res2) B类型的res1和C类型的res2,进行sign操作,返回一个类型是A的结果。 1. 一元运算符重载 (1)重载++ class student { public: in 阅读全文
posted @ 2024-02-06 20:01 拾墨、 阅读(42) 评论(0) 推荐(0)
摘要: 1. 命名空间定义 注:命名空间只能在全局变量中定义 namespace mystd { int x,y; int max(int a,int b) { return std::max(a,b); } } int main() { int a = 10,b = 4; std::cout<<mystd 阅读全文
posted @ 2024-02-06 14:12 拾墨、 阅读(15) 评论(0) 推荐(0)