我只是不明白,这个朋友声明有什么问题,第一个错误消息:
test.cpp: In function 'int main()':
test.cpp:34:7: error: 'void steuerung::exe_testa(testa)' is private
test.cpp:48:15: error: within this context
当 testa 的类声明中的构造函数被删除时,问题正在解决。但我需要一个构造函数。谁能帮帮我吗?真的很谢谢你。
#include <iostream>
class steuerung;
class testb;
class testa;
class testa
{
friend class steuerung;
public:
private:
double a_;
double b_;
};
class testb
{
friend class steuerung;
public:
testb(double a, double b) : a_(a), b_(b) {}
private:
double a_;
double b_;
};
class steuerung
{
friend class testa;
friend class testb;
void exe_testa(testa t_) { t_.b_++; }
//template<class t> void exe(t *t_) { std::cout << t_->a_ << std::endl; }
};
int main ()
{
std::cout << "Laeuft zumindest an.." << std::endl;
testa a;
steuerung s;
s.exe_testa(a);
return 0;
}