Please help me I'm getting frustrated.

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

using namespace std;

int main()
{
    int intList = new intList(8);
    int number;
    cout << "Enter 8 Integers: ";

    for (int count = 0; count < 8; count++)
    {
        cin >> number;
        intList.insertEnd(number);
    }

    cout << endl;
    cout << "Int List";
    intList.print();
    cout << endl;

    cout << "The smallest number in IntList: ";
    intList.min(5);
    cout << endl;

}

Error 3 error C2061: syntax error : identifier 'intList' Line 8
Error 4 error C2228: left of '.insertEnd' must have class/struct/union Line 15
Error 6 error C2228: left of '.min' must have class/struct/union Line 24
Error 5 error C2228: left of '.print' must have class/struct/union Line 20
9 IntelliSense: expected a type specifier Line 8
10 IntelliSense: expression must have class type Line 15
11 IntelliSense: expression must have class type Line 20
12 IntelliSense: expression must have class type Line 24

Recommended Answers

All 9 Replies

I suspect the main problem is on line 8. However without the listing of the unorderedArrayListType class it's hard to say for sure.

On line 8, what are you trying to create?

This: int intList suggests you're trying to create a single int, with the name intList.

This: new suggests you're trying to create some kind of pointer.

A pointer is not an int, so creating an int and then trying to assign the value of a pointer to it is wrong.

What are you trying to create on line 8?

So heres my h file

#ifndef unorderedArrayListType
#define unorderedArrayListType
#include "arrayListType.h"

class unorderedArrayListType:public arrayListType
{
public:
    int *list;
    void insertAt(int location, int insertItem);
    void insertEnd(int insertItem);
    void replaceAt(int location, int repItem);
    void remove(int removeItem);
    void removeAt(int location);
    void removeAll();
    int min(int first, int last);
    int max(int first, int last);
    //Constructors
};
#endif

Warning 1   warning C4094: untagged 'class' declared no symbols Line 18

My cpp file


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

using namespace std;

int main()
{
    int *list = intList(8);
    int number;
    cout << "Enter 8 Integers: ";

    for (int count = 0; count < 8; count++);
    {
        cin >> number;
        *list.insertEnd(number);
    }

    cout << endl;
    cout << "Int List";
    *list.print();
    cout << endl;

    cout << "The smallest number in IntList: ";
    int min(5);
    cout << endl;

}



5   IntelliSense: identifier "intList" is undefined Line 8
6   IntelliSense: expression must have class type   Line 15
7   IntelliSense: expression must have class type   Line 20

Error 2 error C3861: 'intList': identifier not found Line 8
Error 4 error C2228: left of '.print' must have class/struct/union Line 20
Error 3 error C2228: left of '.insertEnd' must have class/struct/union Line 15

Answer the question.

What are you trying to do with this line?
int intList = new intList(8);

Well it wants me to declare the identifier but I'm stuck with that. It eventually needs to read the intList of eight numbers. Make sense?

Ok I fixed as much as I can and now I'm getting unresolved external issues. What does that mean?

Nowhere in your code do you declare a class called intList yet you're trying to assign it to a variable. You can't expect the compiler to know what it is without defining it. Also you appear to be trying to use the functions in the class without declaring an object of that class. I think you might want something like this:

int main()
{
    unorderedArrayListType list;
    list.list = new int[8];
    int number;
    cout << "Enter 8 Integers: ";
    for (int count = 0; count < 8; count++);
    {
        cin >> number;
        list.insertEnd(number);
    }
    cout << endl;
    cout << "Int List";
    list.print();
    cout << endl;
}

You will need a destructor to delete the list.list to release the memory.

Thank you so much! Now my problem is I have zero compiler errors but it refuses to run the program?? I'm running out of steam here haha

You will probably have to submit all the class code(.h and .cpp) for both classes and the code you're using to run it in order for it to be tested.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.