我有一個小問題,Visual Studio編譯器似乎沒有被打擾,但在eclipse和g ++中。operator <=重載2個類並轉換ctor
我有2個班,卡和CardDeck。我確實有運營商< = 2 Carddecks作爲參數,不適用於2卡。我有一個轉換ctor,將卡轉換成甲板。
所以,問題是,當我這樣做:
card1 <= card2
這確實在視覺做工精細,它轉換左側部分甲板上,然後將右,然後做比較。
在G ++,它說:
no match for 'operator<=' (operand types are 'Card' and 'Card')
但不應該有一個。正如我所說我想要轉換器能夠把握雙方並進行比較?
對此有何解釋和解決辦法?
編輯(操作和構造函數聲明和代碼):
CardDeck(const Card&);
friend bool operator<=(const CardDeck&, const CardDeck&);
CardDeck::CardDeck(const Card& card){
_Deck.push_back(card);
}
代碼說超過一千字。請嘗試創建[最小化,完整和可驗證示例](http://stackoverflow.com/help/mcve)並向我們顯示。 –
您的運營商<='是會員還是非會員? – TartanLlama
非會員作爲朋友 – KittyT2016