Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6048751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:29:55+00:00 2026-05-23T07:29:55+00:00

The following are the files involved and a short description: arrayListType.h , arrayListTypeImp.cpp :

  • 0

The following are the files involved and a short description:

arrayListType.h, arrayListTypeImp.cpp: declare and implement arrayListType class and its functions.

unorderedarrayListType.h unorderedArrayListTypeImp.cpp: inherit arrayListType class and declare unorderedarrayListType class and implement virtual functions of arrayListType class.

Ch13_Ex6.cpp: Instantiates an object of class unorderedArrayListType and runs some tests.

I am having a compilation error, which I think is due to the Makefile. The following is the error:

unorderedArrayListTypeImp.cpp:4: error: expected unqualified-id before 'using'
unorderedArrayListTypeImp.cpp: In member function 'virtual void unorderedArrayListType::insertAt(int, int)':
unorderedArrayListTypeImp.cpp:11: error: 'cout' was not declared in this scope
unorderedArrayListTypeImp.cpp:11: error: 'endl' was not declared in this scope
unorderedArrayListTypeImp.cpp:13: error: 'cout' was not declared in this scope

Line 4 has a using namespace std; command. The line before that is #include "arrayListType.h". I have tried the following variations in the Makefile but neither worked:

Version 1

all: Ch13_Ex6

arrayListTypeImp.o: arrayListType.h arrayListTypeImp.cpp
    g++ -c -Wall arrayListType.h arrayListTypeImp.cpp

unorderedArrayListTypeImp.o: arrayListTypeImp.o unorderedArrayListType.h unorderedArrayListTypeImp.cpp
    g++ -c -Wall arrayListTypeImp.o unorderedArrayListType.h unorderedArrayListTypeImp.cpp

Ch13_Ex6.o: Ch13_Ex6.cpp
    g++ -c -Wall Ch13_Ex6.cpp

Ch13_Ex6: arrayListTypeImp.o unorderedArrayListTypeImp.o Ch13_Ex6.o
    g++ -Wall Ch13_Ex6.o arrayListTypeImp.o unorderedArrayListTypeImp.o -o Ch13_Ex6

Version 2:

all: Ch13_Ex6

arrayListTypeImp.o: arrayListType.h arrayListTypeImp.cpp
    g++ -c -Wall arrayListType.h arrayListTypeImp.cpp

unorderedArrayListTypeImp.o: unorderedArrayListType.h unorderedArrayListTypeImp.cpp
    g++ -c -Wall unorderedArrayListType.h unorderedArrayListTypeImp.cpp

Ch13_Ex6.o: Ch13_Ex6.cpp
    g++ -c -Wall Ch13_Ex6.cpp

Ch13_Ex6: arrayListTypeImp.o unorderedArrayListTypeImp.o Ch13_Ex6.o
    g++ -Wall Ch13_Ex6.o arrayListTypeImp.o unorderedArrayListTypeImp.o -o Ch13_Ex6

Both versions compile arrayListTypeImp.o and give the error shown above when compiling unorderedArrayListTypeImp.o. The following is the complete compile output:

make
g++ -c -Wall unorderedArrayListType.h unorderedArrayListTypeImp.cpp 
arrayListTypeImp.o
unorderedArrayListType.h:16: error: expected unqualified-id at end of input
unorderedArrayListTypeImp.cpp:4: error: expected unqualified-id before 'using'
unorderedArrayListTypeImp.cpp: In member function 'virtual void        unorderedArrayListType::insertAt(int, int)':
unorderedArrayListTypeImp.cpp:11: error: 'cout' was not declared in this scope
unorderedArrayListTypeImp.cpp:11: error: 'endl' was not declared in this scope
unorderedArrayListTypeImp.cpp:13: error: 'cout' was not declared in this scope
unorderedArrayListTypeImp.cpp:13: error: 'endl' was not declared in this scope

Code for arrayListType.h:

#ifndef H_arrayListType
#define H_arrayListType

class arrayListType
{
public:
    bool isEmpty() const;
    bool isFull() const;        
    int listSize() const;        
    int maxListSize() const;        
    void print() const;        
    bool isItemAtEqual(int location, int item) const;

    virtual void insertAt(int location, int insertItem) = 0;        
    virtual void insertEnd(int insertItem) = 0;

    void removeAt(int location);        
    int retrieveAt(int location) const;        
    virtual void replaceAt(int location, int repItem) = 0;

    void clearList();

    virtual int seqSearch(int searchItem) const = 0;

    virtual void remove(int removeItem) = 0;

    arrayListType(int size = 100);        
    arrayListType(const arrayListType& otherList);        
    virtual ~arrayListType();

protected:
    int *list;
    int length;
    int maxSize;
};

#endif

Code for unorderArrayListTypeImp.cpp:

#include <iostream>
#include "unorderedArrayListType.h"

using namespace std;

void unorderedArrayListType::insertAt(int location, 
                                  int insertItem)
{
    if (location < 0 || location >= maxSize)
        cout << "The position of the item to be inserted "
             << "is out of range." << endl;
    else if (length >= maxSize)  //list is full
        cout << "Cannot insert in a full list" << endl;
    else
    {
        for (int i = length; i > location; i--)
            list[i] = list[i - 1];  //move the elements down

        list[location] = insertItem; //insert the item at 
                                     //the specified position

        length++;   //increment the length
    }
} //end insertAt

void unorderedArrayListType::insertEnd(int insertItem)
{
    if (length >= maxSize)  //the list is full
        cout << "Cannot insert in a full list." << endl;
    else
    {
        list[length] = insertItem; //insert the item at the end
        length++; //increment the length
    }
} //end insertEnd

// More virtual functions implemented and finally a constructor

unorderedArrayListType::unorderedArrayListType(int size)
                       : arrayListType(size)
{
}  //end constructor
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:29:55+00:00Added an answer on May 23, 2026 at 7:29 am

    You did not #include <iostream> in arrayListType.h, but did it in arrayListType.cpp, before you #include "arrayListType.h" there. You need to place #include <iostream> into arrayListType.h before you use std::cout or std::endl.

    To avoid such mistakes it is good to place the interface header as the first #include statement int the implementation file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the following error when I put class files in subfolders of
The Zend Framework coding standard mentions the following: For files that contain only PHP
I have a simple application with the following code: FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles();
Following on from my recent question regarding parsing XML files in Java I have
The following code snippet illustrates a memory leak when opening XPS files. If you
I have the following command which deletes files that are one day old and
I use the following to get a list of project files that need to
I have the following code to zip all the files and then save it
I want to ran the following script on text files that are being committed:
I need to do the following for hundreds of files: Append the name of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.