MyCAssignmentOprOverload\main.cpp...
main.cpp:29: error: name lookup of `i' changed for new ISO `for' scoping
] C:\Dev-main.cpp:27: error: using obsolete binding at `i'
#include <iostream>
usingnamespace std;
class cAssignmentOprOverload
{
friend ostream& operator<<(ostream&, const cAssignmentOprOverload&);
friend istream& operator>>(istream& , cAssignmentOprOverload& );
public:
const cAssignmentOprOverload& operator=
(const cAssignmentOprOverload& otherList);
//Overloads the assignment operator
void print() const;
//Function to print the list
void insertEnd(int item);
//Function to insert an item at the end of the list
//Postcondition: if the list is not full, length++;
// list[length] = item
// if the list is full, outputs an
// appropriate message
void destroyList();
//Function to destroy the list
//Postcondition: length = 0; maxSize = 0;
// list = NULL
cAssignmentOprOverload(int size = 10);
//constructor
//Postcondition: length = 0; maxSize = size;
// list is an array of size maxSize
private:
int maxSize;
int length;
int *list;
};
I do not know what is obsolete and what has changed in ISO.
In the past the variable (i) defined in the header of the loop could be accessed outside of the loop. This behavior changed so that you cannot access i outside the loop anymore.
2
3
4
5
Press any key to continue . . .
After entering the 4 numbers. the program runs and it bombs out with the message:
[code]
MyCAssignmentOprOverload.exe has stopped working.
A problem caused the program to stop working correctly.
windows will close the program and notify yoy if a solution is available.
then there are two options to choose from.
Either Debug or Close program
Enter the array size: 4
2
3
4
5
Press any key to continue . . .
[code]
MyCAssignmentOprOverload.exe has stopped working.
A problem caused the program to stop working correctly.
windows will close the program and notify yoy if a solution is available.
then there are two options to choose from.
Either Debug or Close program
I got my program to work 100% okay after properly initializing myList and otherList.
My program uses the for loops.
When I try to use the functions : insertEnd(item) and print() I get errors
1 2 3
myList.insertEnd(65);
myList.print();
Here are the errors:
[Error] main.cpp:26: error: request for member `insertEnd' in `myList', which is of non-class type `cAssignmentOprOverload*'
main.cpp:30: error: request for member `print' in `myList', which is of non-class type `cAssignmentOprOverload*'
The objective of the whole exercise was to write the main function to test the functions.
Please advise as to how to test these functions as declared in the header file and implemented in the .cpp file
Thank you very much to all of you!!!
My program worked very well after declaring *myList and *otherList
as objects of the class cAssignmentOprOverload by simply removing the '*' before *myList and *otherList and make them [code] myList and otherList