在头文件中我也使用了
#include <algorithm>
using namespace std;
怎么在编译的时候,对iosfwd文件找出了上百个错误?
对了,我用SDK,不知道能不能这么使用,我是个菜鸟.
如果不能这么用,还有别的什么方法吗?

解决方案 »

  1.   

    我的这个程序没有问题啊#include <algorithm>
    using namespace std;int main(int argc, char* argv[])
    {
    printf("Hello World!\n");
    return 0;
    }
      

  2.   

    然后你再试试stl里面这个random_shuffle的例子:
    //////////////////////////////////////////////////////////////////////
    //
    // Compile options needed: /GX
    //
    // random_shuffle.cpp : Illustrates how to use the random_shuffle
    //                      function.
    //
    // Functions:
    //
    //     random_shuffle : Shuffle the elements in a random order.
    //////////////////////////////////////////////////////////////////////// disable warning C4786: symbol greater than 255 character,
    // okay to ignore
    #pragma warning(disable: 4786)#include <iostream>
    #include <algorithm>
    #include <functional>
    #include <vector>using namespace std ;void main()
    {
        const int VECTOR_SIZE = 8 ;    // Define a template class vector of int
        typedef vector<int> IntVector ;    //Define an iterator for template class vector of strings
        typedef IntVector::iterator IntVectorIt ;    IntVector Numbers(VECTOR_SIZE) ;    IntVectorIt start, end, it ;    // Initialize vector Numbers
        Numbers[0] = 4 ;
        Numbers[1] = 10;
        Numbers[2] = 70 ;
        Numbers[3] = 30 ;
        Numbers[4] = 10;
        Numbers[5] = 69 ;
        Numbers[6] = 96 ;
        Numbers[7] = 100;    start = Numbers.begin() ;   // location of first
                                    // element of Numbers    end = Numbers.end() ;       // one past the location
                                    // last element of Numbers    cout << "Before calling random_shuffle\n" << endl ;    // print content of Numbers
        cout << "Numbers { " ;
        for(it = start; it != end; it++)
            cout << *it << " " ;
        cout << " }\n" << endl ;    // shuffle the elements in a random order
        random_shuffle(start, end) ;    cout << "After calling random_shuffle\n" << endl ;    cout << "Numbers { " ;
        for(it = start; it != end; it++)
            cout << *it << " " ;
        cout << " }\n" << endl ;
    }
      

  3.   

    #include <time.h>
    void main()
    {
    srand( (unsigned)time( NULL ) ); // 一开始补上这句, 否则每次运行打乱的顺序都是一样
    ...
      

  4.   

    我这样使用的:
    #include <windows.h>
    #include <stdio.h>
    #include <time.h>
    #include <mmsystem.h>
    #include <math.h>
    #include <algorithm>
    using namespace std;
    后面是程序码,程序都没有问题,编译错误是:
    c:\program files\microsoft visual studio\vc98\include\iosfwd(24) : error C2143: syntax error : missing '{' before '<'
    这些之类的,到底是什么原因?
      

  5.   

    在所有的include之前加一个#include <stdafx.h>试试