#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 << "發(fā)病了" << 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 << "構(gòu)造完成导披!" << 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如果網(wǎng)上各種誤人子弟的方法可以解決問(wèn)題的話 我就不在這逼逼了 重點(diǎn):出現(xiàn)這個(gè)肯定是你的代碼的問(wèn)題 VS自己少東西的可能性幾乎為0 而問(wèn)題基本都出在指針的使用上 一般都是你調(diào)用...