本文介绍了如何将另一个类中的类的Array用作数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#including Hello ''guys'';
// i have a dump question, my mind isn''t working now
HOW can i use these classes together(please_help_me A)?
----------------------------------------- -------------------------------------
------------------------------------------------------------------------------
class student
{
public:
student();
~student();
int age;
int ID;
// want MAX 10 year for a student
Year YEAR[10]; //<------ ERROR
};
student::student()
{
//What should i do for declaring Array YEAR
}
class Year
{
public:
Year();
~Year();
string name;
int _year;
//want MAX 7 book for a year
book BOOK[]; //<------ ERROR
//book BOOK[7]; ???
};
Year::Year()
{
//Same Problem . .. !
}
class book
{
public:
book();
~book();
int ID;
string name;
};
推荐答案
#include <vector>
class a
{};
std::vector<a> a_arr;
a ob;
a_arr.push_back(ob);
</a>
这篇关于如何将另一个类中的类的Array用作数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!