I get the following error in Eclipse when trying to compile (c++)
../CardDeck.cpp:17:22: error: passing ‘const CardDeck’ as ‘this’ argument of ‘int CardDeck::size()’ discards qualifiers [-fpermissive]
if I change int size() method to int size() const the error msg is gone and its compiled. I dont know why ?
the .H file is the following :
  #include "Card.h"
#include <vector>
using namespace std;
class CardDeck{
    private:
        vector<Card*> deck;
    public:
        int size();
        CardDeck();
        CardDeck(const CardDeck& rhs);
        CardDeck& operator=(const CardDeck& rhs);
        Card& draw();
        Card& top();
        bool isEmpty();
        void clear();
        int value();
        CardDeck& operator+=(const CardDeck& rhs); /// not sure if to return ref
        CardDeck& operator+(const CardDeck& rhs);
        friend CardDeck&  operator*(unsigned int num,CardDeck& rhs);
        friend CardDeck&  operator*(CardDeck& lhs,unsigned int num);
        bool operator<=(const CardDeck& rhs );
        bool operator>=(const CardDeck& rhs);
        bool operator<(const CardDeck& rhs);
        bool operator>(const CardDeck& rhs);
        bool operator==(const CardDeck& rhs);
        bool operator!=(const CardDeck& rhs);
        Card*  operator[](int i);
};
and the C++ file is :
#include "CardDeck.h"
int CardDeck::size() {
    return this->deck.size();
}
CardDeck::CardDeck(){};
CardDeck::CardDeck(const CardDeck& rhs){
    this->clear();
    int i;
    for (i=0;i<rhs.size();i++){
        Card* current_card = rhs.deck[i];
        Card* new_copy = new Card(*current_card);
        this->deck.push_back(new_copy);
    }
}
Card* CardDeck::operator[](int i) {
    return this->deck[i];
}
void CardDeck::clear(){
    vector<Card*>::iterator it ;
    for(it=this->deck.begin();it != this->deck.end();++it){
        Card* temp = *it;
        this->deck.erase(it);
        delete(temp);
    }
}