gpt4 book ai didi

c++ - 在 C++ 中写入文件的编译错误

转载 作者:太空狗 更新时间:2023-10-29 23:02:59 26 4
gpt4 key购买 nike

有人能解释一下我做错了什么吗?根据编译器的输出,每一行都必须至少包含一个错误。但是 C2297 错误似乎没有多大意义,因为我发现了使用常量 char 数组 cplusplus.com tutorial 写入的示例?

#include <iostream>
#include <fstream>
#include "stdafx.h"
#include "accelerators/tree.h"
#include "paramset.h"
#include "shapes/trianglemesh.h"

void Tree::PrintTree() const {
std::ofstream myfile;
myfile.open("RTSAH.txt");

for (uint32_t i = 0; i < nextFreeNode; ++i) {
const KdAccelNode* node = &nodes[i];
if (node->IsLeaf()) {
myfile << i;
myfile << " L ";
myfile << node->nPrimitives() << std::endl;
}
else {
myfile << i;
myfile << " I ";
myfile << "SP= ";
myfile << node->SplitPos();
myfile << " SA= ";
myfile << node->SplitAxis();
myfile << " BC= ";
myfile << (i + 1);
myfile << " AC= ";
myfile << node->AboveChild() << std::endl;
}
}
myfile.close();
}

enter image description here

最佳答案

由于第一个错误报告无法弄清楚 myfile 是什么,任何使用 myfile 的后续代码几乎肯定会产生错误,即使它是正确的。

关于c++ - 在 C++ 中写入文件的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26868031/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com