CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Nov 2011
    Posts
    27

    [RESOLVED] at a loss with overloading opperators

    Code:
    friend ostream& operator<<(ostream& ostm, const Mixed& m);
    	friend istream& operator>>(istream& istm, Mixed& m);
    	friend bool operator<(const Mixed& lhs, const Mixed& rhs);
    	friend bool operator>(const Mixed& lhs, const Mixed& rhs);
    	friend bool operator<=(const Mixed& lhs, const Mixed& rhs);
    	friend bool operator>=(const Mixed& lhs, const Mixed& rhs);
    	friend bool operator==(const Mixed& lhs, const Mixed& rhs);
    	friend bool operator!=(const Mixed& lhs, const Mixed& rhs);
        friend Mixed operator+(const Mixed& lhs, const Mixed& rhs);
        friend Mixed operator-(const Mixed& lhs, const Mixed& rhs);
        friend Mixed operator*(const Mixed& lhs, const Mixed& rhs);	 
        friend Mixed operator/(const Mixed& lhs, const Mixed& rhs);	 
        friend Mixed operator++(Mixed& m, int);
        friend Mixed operator++(Mixed& m);
        friend Mixed operator--(Mixed& m, int);
        friend Mixed operator--(Mixed& m);
    i keep getting errors with all 6 with bool when i dont comment them out in the driver if you need my .h and 2 .cpp files let me know! thank you!
    Code:
     1>main.obj : error LNK2019: unresolved external symbol "bool __cdecl operator<(class Mixed const &,class Mixed const &)" (??M@YA_NABVMixed@@0@Z) referenced in function _main
    1>c:\users\austin\documents\visual studio 2010\Projects\finalff\Debug\finalff.exe : fatal error LNK1120: 1 unresolved externals

    more info
    Code:
    // demonstrate comparison overloads
      if (x < y)	cout << "(x < y) is TRUE\n";
      if (x > y)	cout << "(x > y) is TRUE\n";
      if (x <= y)	cout << "(x <= y) is TRUE\n";
      if (x >= y)	cout << "(x >= y) is TRUE\n";
      if (x == y)	cout << "(x == y) is TRUE\n";
      if (x != y)	cout << "(x != y) is TRUE\n";
    Last edited by austinm6; February 14th, 2012 at 01:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured