これbasic_istream::tellg()
は、 VS2010での関数の定義です。この関数は type の変数を返すことに注意してくださいpos_type
。ただし、streamoff
以下の例で使用されている型を で置き換えるpos_type
と、コンパイラは文句を言います (C2065: 'pos_type' : undeclared identifier)。
pos_type
で定義され<fstream>
ていtypedef typename _Traits::pos_type pos_type;
ます。
// basic_istream_tellg.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>
int main()
{
using namespace std;
ifstream file;
char c;
streamoff i; // compiler complains if I replace streamoff by pos_type
file.open("basic_istream_tellg.txt");
i = file.tellg();
file >> c;
cout << c << " " << i << endl;
i = file.tellg();
file >> c;
cout << c << " " << i << endl;
}