标签:函数 span -- str .net public center space 声明
编敲代码过程中遇到重定义默认參数的错误,例如以下例所看到的:
#include<iostream>
#include<stdlib.h>
using namespace std;
class Student
{
private:
int number;
char name[10];
public:
Student(int n = 0, char *s = "no name");
};
Student::Student(int n = 0, char *s = "no name")
{
number = n;
strcpy_s(name, s);
}
int main()
{
Student s1;
return 0;
}
请教他人发现了原因所在:
1:參数的默认值仅仅能够出如今函数声明中,不能够出如今函数的定义中,否则会出现參数反复定义默认參数的错误---->>语法规定
建议编程者还是按标准做得好
标签:函数 span -- str .net public center space 声明
原文地址:http://www.cnblogs.com/yfceshi/p/7067035.html