#include<iostream>
#include<ctime>
#include<fstream>
#include<string>
#include<stack>
#include<vector>
#include<map>
using namespace std;
class Name {
public:
char* first;
char* second;
char* third;
public:
Name(string f = "", string s = "", string t = "")
{
first = new char[f.length() + 1];
second = new char[s.length() + 1];
third = new char[t.length() + 1];
strcpy_s(first, f.length() + 1, f.c_str());
strcpy_s(second, s.length() + 1, s.c_str());
strcpy_s(third, t.length() + 1, t.c_str());
}
Name(Name& name)
{
int flen = std::string(name.first).length();
int slen = std::string(name.second).length();
int thlen = std::string(name.third).length();
first = new char[flen + 1];
second = new char[slen + 1];
third = new char[thlen + 1];
strcpy_s(first, flen + 1, std::string(name.first).c_str());
strcpy_s(second, slen + 1, std::string(name.second).c_str());
strcpy_s(third, thlen + 1, std::string(name.third).c_str());
}
~Name()
{
cout << "发病了" << endl;
delete first;
delete second;
delete third;
}
void Printname()
{
cout << first << " " << second << " " << third << endl;
}
};
class Person
{
private:
Name n;
string sex;
string national;
public:
Person(Name a, string sex, string national) :n(a), sex(sex), national(national)
{
cout << "构造完成!" << endl;
}
void printName()
{
n.Printname();
}
void printNational()
{
cout << national << endl;
}
};
int main()
{
Name name("比利王", "搞比利", "大xx");
Person s(name, "男", "日暮里");
s.printName();
s.printNational();
}
C++ VS提示未加载 wntdll.pdb如果网上各种误人子弟的方法可以解决问题的话 我就不在这逼逼了 重点:出现这个肯定是你的代码的问题 VS自己少东西的可能性几乎为0 而问题基本都出在指针的使用上 一般都是你调用...