小白求助 关于在主函数中传递字符串参数到类中的问题
#define _CRT_SECURE_NO_WARNINGS#include "iostream"
#include "MyVector.cpp"
using std::endl;
using std::cin;
using std::cout;
class Teacher
{
private:
int age;
char name[20];
public:
Teacher()
{
age = 33;
strcpy(name, " ");
}
Teacher(char* name, int age)
{
this->age = age;
strcpy(this->name, name);
}
void printT()
{
cout << this->age << " " << this->name << endl;
}
};
void main()
{
{
Teacher t1("t1", 22), t2("t2", 32), t3("t3", 42), t4("t4", 52);
MyVector<Teacher> tArray[4];
tArray[0] = t1;
tArray[1] = t2;
tArray[2] = t3;
tArray[3] = t4;
}
system("pause");
}