"Not a class or namespace name" error

I'm getting a large set of errors that all seem to deal with the class not being found. Here's a few:

-error C2653: 'sequence' : is not a class or namespace name
-missing type specifier - int assumed. Note: C++ does not support default-int (this line uses value_type, where in the header file value_type was defined as an int)
-error C3861: 'is_item': identifier not found

The header file (and usage file, though I'm assuming the issue is with the implementation/header file) were provided by the instructor. The implementation file was also provided, just missing most of the logic coding, but it included most of the technical code.

Anyways, if anyone could try and help me with the reason that the class isn't being found (or if that's not the error at all, I've had a few misleading errors in my previous class), it would be much appreciated.

Here's the header file:

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// FILE: sequence1.h
// CLASS PROVIDED: sequence (part of the namespace main_savitch_3)
//
// TYPEDEFS and MEMBER CONSTANTS for the sequence class:
//   typedef ____ value_type
//     sequence::value_type is the data type of the items in the sequence. It
//     may be any of the C++ built-in types (int, char, etc.), or a class with a
//     default constructor, an assignment operator, and a copy constructor.
//
//   typedef ____ size_type
//     sequence::size_type is the data type of any variable that keeps track of
//     how many items are in a sequence.
//
//   static const size_type CAPACITY = _____
//     sequence::CAPACITY is the maximum number of items that a sequence can hold.
//
// CONSTRUCTOR for the sequence class:
//   sequence( )
//     Postcondition: The sequence has been initialized as an empty sequence.
//
// MODIFICATION MEMBER FUNCTIONS for the sequence class:
//   void start( )
//     Postcondition: The first item on the sequence becomes the current item
//     (but if the sequence is empty, then there is no current item).
//
//   void advance( )
//     Precondition: is_item returns true.
//     Postcondition: If the current item was already the last item in the
//     sequence, then there is no longer any current item. Otherwise, the new
//     current item is the item immediately after the original current item.
//
//   void insert(const value_type& entry)
//     Precondition: size( ) < CAPACITY.
//     Postcondition: A new copy of entry has been inserted in the sequence
//     before the current item. If there was no current item, then the new entry 
//     has been inserted at the front of the sequence. In either case, the newly
//     inserted item is now the current item of the sequence.
//
//   void attach(const value_type& entry)
//     Precondition: size( ) < CAPACITY.
//     Postcondition: A new copy of entry has been inserted in the sequence after
//     the current item. If there was no current item, then the new entry has 
//     been attached to the end of the sequence. In either case, the newly
//     inserted item is now the current item of the sequence.
//
//   void remove_current( )
//     Precondition: is_item returns true.
//     Postcondition: The current item has been removed from the sequence, and the
//     item after this (if there is one) is now the new current item.
//
// CONSTANT MEMBER FUNCTIONS for the sequence class:
//   size_type size( ) const
//     Postcondition: The return value is the number of items in the sequence.
//
//   bool is_item( ) const
//     Postcondition: A true return value indicates that there is a valid
//     "current" item that may be retrieved by activating the current
//     member function (listed below). A false return value indicates that
//     there is no valid current item.
//
//   value_type current( ) const
//     Precondition: is_item( ) returns true.
//     Postcondition: The item returned is the current item in the sequence.
//
// VALUE SEMANTICS for the sequence class:
//    Assignments and the copy constructor may be used with sequence objects.

#ifndef MAIN_SAVITCH_SEQUENCE_H
#define MAIN_SAVITCH_SEQUENCE_H
#include <cstdlib>  // Provides size_t

namespace main_savitch_3
{
    class sequence
    {
    public:
        // TYPEDEFS and MEMBER CONSTANTS
        typedef double value_type;
        //     typedef std::size_t size_type;
        //     static const size_type CAPACITY = 30;
		typedef size_t size_type;
		enum {CAPACITY = 30};
        // CONSTRUCTOR
        sequence( );
        // MODIFICATION MEMBER FUNCTIONS
        void start( ) { current_index = 0; };
        void advance( );
        void insert(const value_type& entry);
        void attach(const value_type& entry);
        void remove_current( );
        // CONSTANT MEMBER FUNCTIONS
		size_type size( ) const  { return used; };
		bool is_item( ) const { return (current_index < used); };
        value_type current( ) const;
    private:
        value_type data[CAPACITY];
        size_type used;
        size_type current_index;
    };
}

#endif 



And here's the implementation file:

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// FILE: seqeunce1.cxx
// CLASS IMPLEMENTED: seqeunce: (See seqeunce1.h for documentation)
// INVARIANT for the sequence class ADT
//  1. The number of items in the sequence is stored in the member variable used.
//  2. For an empty sequence, we do not care what is stored in the array data[],
//     otherwise, the items are stored in data[0] to data[used-1]. 
//     Note: data[used] is junk or does not exist
//  3. If there is a current_item() then it is stored in data[current_index].
//     Note: 0 <= current_index <= used. If current_index < used then is_item()
//           is true, otherwise it is false

#include <iostream>  // provides cout
#include <cassert>   // provides assert
#include <cstdlib>   // provides size_t
#include "sequence1.h"
using namespace std;

namespace main_savitch_3
{
	sequence::sequence()
	{
		current_index = 0;
		used = 0;
	}

	void sequence::advance()
	{
		assert(is_item());
		++current_index;
	}

	void sequence::insert(const value_type& entry)
	{
		assert( used < CAPACITY);

		if (current_index == used)
			current_index = 0;


		for (size_t i = used; i > current_index; --i)
		{
			data[i] = data[i-1];
		}

		data[current_index] = entry;
		++used;
		return;
		}
	}


	void sequence::attach(const value_type& entry)
	{
		cout << "Not written yet!\n\n";
		return;
	}

	void sequence::remove_current()
	{
		cout << "Not written yet!\n\n";
		return;
	}

	sequence::value_type sequence::current() const
	{
		assert (is_item());
		return data[current_index];
	}

}




(Not entirely sure if insert is done correctly, was my first attempt after trimming it down a lot, but I'm not concerned about that. The original implementation file with the unwritten insert (well, includes the assert and the "I'm not written" message) gives the same errors.)

I won't include the usage file, as it was done entirely by the textbook author, and I haven't heard of any problems with it from my instructor, but let me know if it's necessary.
Look at line 49 in sequence.cxx, it is an unpaired }
You really don't need to screw up much to get a slew of errors...

Thanks for the reply.
Topic archived. No new replies allowed.