c++学习
xiao_song_shu
这个作者很懒,什么都没留下…
展开
-
建立一个对象数组,内放5个学生的数据(学号,成绩),用指向对象的指针做函数参数,在max函数中找出5个学生中成绩最高者,并输出其学号。
源代码如下:主要注意友元函数的声明#include #include using namespace std;class Student{public: Student(string n,float s):number(n),score(s){} friend void max(Student *); //声明友元函数private: s原创 2017-04-05 14:33:27 · 21147 阅读 · 3 评论 -
为什么使用close()关闭所打开文件
如果程序没有用close()主动关闭文件,则在文件流对象退出其作用域时,被自动调用的析构函数会关闭该对象所联系的文件。提倡在打开的文件不再需要时及时并主动地将之关闭,以便尽早的释放所占用的系统资源并尽早将文件置于更安全的状态。如果在没有关闭文件的情况下再打开相同的文件,则此时无法再向里面写入数据。因为资源被占用,再加上析构函数没有调用,即文件流对象还没退出其作用域,情况容易在递归或者循环中发生原创 2017-08-07 17:22:12 · 3535 阅读 · 0 评论 -
MFC出现XXX is not a precompiled header file created with this compiler
将debug文件夹删除,再重新打开编译即可。原创 2017-05-30 09:39:00 · 2853 阅读 · 0 评论 -
C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
C++在将整型、浮点型、长整型等数据类型转换为字符串时,可使用在头文件包含的函数:to_string(). 函数原型如下: string to_string (int val); string to_string (float val); string to_string (double val); string to原创 2017-08-08 19:32:29 · 10418 阅读 · 0 评论