Hello Everyone,

I am getting the following error on line 12.

"variable or field 'start' declared void"

I have deleted quite a bit of code, in case your wondering what the program is supposed to do. I don't understand why the compiler would have a problem with this function being void when it does not return anything.

#include "utility.h"
#include "Item.h"
#include "Event.h"
using namespace std;

template< typename T > void printStack( T &stackRef );
template< typename T > void printQueue( T &queueRef );
template <typename InputIterator> void printList(InputIterator first, InputIterator last);
template< typename T > bool checkQueue( T &queueRef );
template< typename T > void loadPlane( T &chiStack, T &mempStack);
template< typename T >void start( List<Event> &mylist, T &ePackage, T &ePlane, T &endOfService );

int main()
    const int maxTime = 2000;
    stack< Item > chicagoStack;
    stack< Item > memphisStack;
    queue< Item > packageQueue;
    queue< Item > planeQueue;
    list<Event> mylist;
	list<Event>::iterator current;                                      //pointer into the list

	Item iPackage;
	Item iPlane;
    Event ePackage;
    Event ePlane;
    Event endOfService;

    int time = 0;

template< typename T >void start( List<Event> &mylist, T &ePackage, T &ePlane, T &endOfService )
    ePackage.makeEvent(5, "package", "Memphis");

    endOfService.makeEvent(8, "End of Service", "endOfService");

    ePlane.makeEvent(6, "planeChicago", "Chicago");

    ePlane.makeEvent(5, "planeMemphis", "Memphis");


Edited by coolbeanbob: n/a

5 Years
Discussion Span
Last Post by coolbeanbob

You wrote "List" instead of "list", C++ is a case-sensitive language.

Because the compiler does not recognize the "List" as a type (and thus starting a declaration of a parameter-list), it thinks that line 12 is a declaration (and initialization) of a "variable or field" called "start" and because it sees it as a "void" type, it gives a compilation error.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.