You are not logged in.

#1 2011-04-26 01:06:32

sackocool
Member
Registered: 2011-04-26
Posts: 3

[SOLVED] ISO C++ forbids declaration of ‘linkedStackType’ with no type

I got an error when building my program. The program was working fine for a while before showing this error:
    In file included from truck.cpp:1:
    truck.h:62: error: ISO C++ forbids declaration of ‘linkedStackType’ with no type
    truck.h:62: error: expected ‘;’ before ‘<’ token
    truck.h:63: error: ISO C++ forbids declaration of ‘linkedStackType’ with no type
    truck.h:63: error: expected ‘;’ before ‘<’ token

#include "orderedLinkedList.h"
#include <string>
#include <iostream>
using namespace std;

#ifndef TRUCK_H
#define    TRUCK_H

class truck {
public:
    truck();
    // default constructor; number and price are are set to -1 and sold is set
    // to false

    truck(int truckNumber, string typeOfLoading);
    // constructor

    truck(truck &s);
    // copy constructor

    ~truck();
    // destructor

    bool hasCargo ();
    void addItems (string items);

    void unload ();
    void load ();

    int getTruckNumber();
    string getTypeOfLoading();

    bool operator==(const truck &s) const;
    
    bool operator!=(const truck &s) const;

    const truck & operator=(const truck &s);
    
    friend istream & operator>>(istream &in, truck &s);
    
    friend ostream & operator<<(ostream &out, truck &s);
    
    linkedStackType<string> pickupCargo;
    linkedStackType<string> deliveryCargo;

private:
    int truckNumber;
    string typeOfLoading;
    
    orderedLinkedList<string> cargoItems;
    linkedListIterator<string> *cargoIterator;
};

#endif    /* TRUCK_H */

Moderator:  [ewaller] I fixed your code tags for you

Last edited by sackocool (2011-04-26 03:58:43)

Offline

#2 2011-04-26 01:17:29

Allan
Developer
From: Brisbane, AU
Registered: 2007-06-09
Posts: 10,408
Website

Re: [SOLVED] ISO C++ forbids declaration of ‘linkedStackType’ with no type

You need to use "[" brackets for your code blocks....


Anyway...   do you include the header for your  "linkedStackType" in there?  It does not look like it unless that is in "orderedLinkedList.h".

Offline

#3 2011-04-26 01:30:32

sackocool
Member
Registered: 2011-04-26
Posts: 3

Re: [SOLVED] ISO C++ forbids declaration of ‘linkedStackType’ with no type

Thank you so much. I had so many reciprocal including I thought it was included by linkedList which is included by orderedLinkedList.h. Thanks again.

Offline

#4 2011-04-26 01:39:01

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 6,831

Re: [SOLVED] ISO C++ forbids declaration of ‘linkedStackType’ with no type

Please mark the thread as [SOLVED] once it is. Edit your first post (you should also use proper code tags as Allan said).


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#5 2011-04-26 03:18:59

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: [SOLVED] ISO C++ forbids declaration of ‘linkedStackType’ with no type

sackocool wrote:

Thank you so much. I had so many reciprocal including I thought it was included by linkedList which is included by orderedLinkedList.h. Thanks again.

Don't depend on that type of including.  If your source file depends on a definition, include the header that contains that definition; don't expect some other header to include it for you.   

Related: ensure all your headers are multi-include-safe (with a nice big #ifndef at the top) - I see you doing this in the file you pasted, so good stuff smile

Offline

#6 2011-04-26 03:56:08

sackocool
Member
Registered: 2011-04-26
Posts: 3

Re: [SOLVED] ISO C++ forbids declaration of ‘linkedStackType’ with no type

Yeah I got your point. Thanks a lot.

Offline

Board footer

Powered by FluxBB