error C2871: 'std': a namespace ... does not exist

error C2871: 'std' : a namespace with this name does not exist

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
#include <cstdlib> //added http://forums.devx.com/showthread.php?t=152439
#include <string>
#include <iostream>
#include <fstream>
#include "iterator.h" 
#include "genlib.h"
#include "stdafx.h"

using namespace std;

template <typename ElemType>
Iterator<ElemType>::Iterator()
{
    start = NULL;
	tail = NULL;
}

... */


the existing forum threads relate to not having header files for std, but I have these?
I believe the person in that threads problem was they needed to include <string>. I dont know what your issue is as you haven't provided any useful code to test.
Eh? All of that code is commented.
yes, it is commented - a typo during copy/paste.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "stdafx.h"
#include <cstdlib> //added http://forums.devx.com/showthread.php?t=152439
#include <string>
#include <iostream>
#include <fstream>
#include "iterator.h" 
#include "genlib.h"

using namespace std;

template <typename ElemType>
Iterator<ElemType>::Iterator()
{
    start = NULL;
	tail = NULL;
}

template <typename ElemType>
Iterator<ElemType>::~Iterator()
{
	// This should be left empty for very subtle reasons
}

template <typename ElemType>
bool Iterator<ElemType>::hasNext()
{
  	  return (start != NULL);
}

template <typename ElemType>
ElemType Iterator<ElemType>::next()
{
    cellT *cp = start;
    if (cp == NULL) Error("Next called on empty iterator");
    ElemType elem = cp->elem;
    start = cp->link;
    delete cp;
    return elem;
}

template <typename ElemType>
void Iterator<ElemType>::add(ElemType elem)
{
    cellT *cp = new cellT;
    cp->elem = elem;
    cp->link = NULL;
    if (tail == NULL) {
        start = cp;
    } else {
        tail->link = cp;
    }
    tail = cp;
}
That's bizarre. Unless something weird's going on in compiler settings (I'm guessing you're using VS), there's no reason that should be happening.
the errors gone, I moved #include "stdafx.h" to the top and closed VS then reopend the project
Topic archived. No new replies allowed.