我有一个动态的结构数组。当我说动态时,我的意思是元素的数量可以随着程序的运行而变化。在尝试将实例变量作为数组使用之后,我一直有不兼容的类型问题。还有其他方法吗?C++实例变量/指向堆中数组的指针
我有这样的结构:
struct movie
{
int rank;
string title;
string distributor;
string weekend;
string total;
} ;
我有这个类的头文件:
class ReadFile{
public:
ifstream moviesFile;
movie movies[];
ReadFile(string);
movie handleLine(string);
string getString(vector<char>);
};
这是我正在试图实例化电影实例变量:
//Some code
movie temparray[linecount];
//temparray is filled with various movie structures.
movies = temparray;
这是当我得到我的错误。我将如何完成实例化我的电影数组的任务。谢谢!
格式化问题而不是使用HTML标记时,选择代码并按CTRL + K使其格式正确。 – Naveen 2011-03-18 07:06:59
'ReadFile'作为(非函子)类的名称听起来有点可疑。精心设计的类通常代表名词,而不是动词。 – 2011-03-18 07:18:57