#include<iostream>
#include<cstring>
using namespace std;
class studentID
{
public:
studentID(int d = 0)
{
value = d; cout << " Assigning student id " << value << endl;
}
~studentID()
{
cout << "Destructing id " << value << endl;
}
protected: int value;
};
class student
{
public:
student(const char* pname = " no name ", int ssID = 0) : id(ssID)
{
cout << " Constructing student " << pname << endl;
strncpy(name, pname, sizeof(pname));
name[sizeof(name) - 1] = '\n';
}
protected: char name[20]; studentID id;
};
int main()
{
student s("Ranry", 9818); student t("Jenny");
return 0;
}
PS 当我 Ctrl + a 全选代码,有没将源代码删除,保持全选状态,直接 Ctrl + v 粘贴一个 hello world 的程序,还是相同的报错。但是,如果我不保持全选状态,而是全选后直接用退格键全部删除,再粘贴 hello world 程序,就成功输出 hello world
。
报错:
错误 LNK1120 1 个无法解析的外部命令
错误 LNK2019 无法解析的外部符号 main,函数 "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) 中引用了该符号