我正在使用 c++,以下是我的代码:
测试.h
char[] defaultSurname = "salunke";
void in_dev(const char* name, char* surname = defaultSurname );
测试.cpp
#include "test.h"
#include <iostream>
using namespace std;
void in_dev(const char* name, char* surname)
{
cout <<" surname id "<< surname << endl;
}
int main()
{
in_dev("Balaji", "Patil");
return 0;
}
但它给出了以下编译错误:
test.h:1: error: expected unqualified-id before '[' token
test.h:9: error: 'defaultSurname' was not declared in this scope
如何解决此错误?