문제

I get an illegal indirection error at generateCSVHeader(*file4);.

function declaration:

void generateCSVHeader(QFile * file);

function use:

str="MyData.csv";
QFile file4(str);
generateCSVHeader(*file4);

when I drop the dereference designator, it gives me a cannot convert QFIle to QFile * error.

도움이 되었습니까?

해결책

You should pass pointer to your QFile object (which is an address) instead of passing the object itself (dereferencing is irrelevant, because it is used only with pointers, not objects). To get an address of your object, you should use the & operator. So you have to invoke your function like this:

generateCSVHeader(&file4)

Also, you may consider using references instead of pointers.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top