我在wxWidgets和其他C++代码风格中看到了这一点:
#include <iostream>
class Foo {
int _x;
int _y;
public:
Foo () : _x(0), _y(0) {}
Foo (int x, int y) : _x(x), _y(y) {}
int get () const { return _x+_y; }
};
int GetFoo (const Foo& f) {
return f.get ();
}
int main () {
Foo f1(2,3); // create object with values
std::cout << "Value1: " << f1.get () << '\n'; // access object method
std::cout << "Value2: " << GetFoo(Foo(3,7)) << '\n'; // How do you call this?
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当你使用带有某些值的直接类时.我把它命名为直接类作为对象,但我想知道这个用语.谢谢.