我是C ++的新手,但是我以前有PHP和C#(OOP)编程经验。我所拥有的是:两个类,其中一个具有另一个类的私有属性。来源:
class Foo
{
public:
Foo(int n)
{
}
};
class Bar
{
private:
Foo foo;
public:
Bar()
{
this->foo = Foo(10);
}
};
Bar bars[123];
我想做的是在中声明一个Foo
带有构造函数的属性Bar
。不幸的是,我这样做的方式行不通。它给出了一系列错误,例如
没有匹配的函数来调用'Foo :: Foo()'
我该如何运作?感谢您的回复。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句