在这个完整的代码中:
class foo
{
public:
foo(const int pin);
};
class bar {
public:
// Constructor
bar(const int dataPin) : dataPin_ (dataPin) { }
private:
const int dataPin_;
foo myFoo_ (dataPin_); // instance of foo
};
int main (void)
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
使用g ++ 4.8.4我收到错误:
g++ -Wall -c "test.cpp" (in directory: /home/nick/Development)
test.cpp:14:17: error: ‘dataPin_’ is not a type
foo myFoo_ (dataPin_); // instance of foo
^
Compilation failed.
Run Code Online (Sandbox Code Playgroud)
使用clang 3.4-1ubuntu3我得到:
test.cpp:14:17: error: unknown type name 'dataPin_'
foo myFoo_ (dataPin_); …Run Code Online (Sandbox Code Playgroud)