intのリストへの参照を宣言しようとしています。私がコンパイルすると、expected '(' for function-style cast or type construction
のエラーlist<int>& current;
が出てきます。ここで私は参照を宣言しています。ここの問題は何ですか?私は全面的に見て、これは参照がどのように初期化されているかのようです。私はそれがコンパイルされないので、逃した何かがあるに違いありません。参照の初期化時にエラーが発生する
#include <iostream>
#include <vector>
#include <list>
using namespace std;
int main() {
list<int> list;
list<int>& current;
current = list; // or just list<int>& current = list; both error
}
参照はオブジェクトの別の名前なので、すべての参照を初期化する必要があります。単純に次のように書くことはできません。int & r; int d; int&r = d; – AnatolyS