Latest Lists

Help needed correcting this template.?

I have written a palindrome templae that is supposed to test provided vectors to see if they read the same forwards and backwards. It is supposed to return a bool TRUE or FALSE based on the results. This is what I have so far but there is a problem that I am having trouble figuring out. I am using Visual C++ for this. #include "stdafx.h" #include "iostream" using namespace std; template <class T> class Palindrome { public: bool sort(); void insert(const T& item, int position); Palindrome(int listSize = 10); ~Palindrome(); private: int maxSize; int length; T *list; }; template <class T> bool Palindrome<T>::sort() { int i; for (i = 0; i < length; i++) { if(list[i] == list [length-1-i]) continue; else return false; } return true; } template <class T> void Palindrome<T>::insert(const T& item, int position) { insert(position >= 0 && position < maxSize); list[position] = item; length++; } int main() { int size, numeric; Palindrome<int> intList(10); cout << "How many numbers are in the vector? "; cin >> size; cout << "Enter your numbers" << size << endl; for(int i = 0; i < size; i++) { cin >> numeric; intList.insert(numeric, i); } if(intList.sort()) cout << "Your integers are a palindrome!" << endl; else cout << "Your integers are not a palindromme." << endl; return 0; } The error I get points to this line: insert(position >= 0 && position < maxSize); What is needed to correct this?

Public Comments

  1. insert is a function that takes two arguments, in that line, you only have one argument
Powered by Yahoo! Answers