Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++ 2005
Visual C++ 2005 For discussion of Visual C++ 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 22nd, 2006, 06:49 PM
Authorized User
Join Date: Apr 2005
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default Arraylist::Sort() by class member

I have an ArrayList which stores different instances of a class, which contains 3 integers. I wish to sort the ArrayList by 1 of these integers. I'm sure it's possible but can't find anything on the internet to show me how, can anyone help?
I know I have to use an interface class using IComparer, but all of my attempts at using this have failed, so I would really appreciate some help!!
At the moment my declaration for this class is:

public interface class DataComparer : public IComparer
        int Compare(Object^ lhv, Object^ rhv)

and the usage of it is:

Arlist->Sort(gcnew DataComparer)

I get the errors:

error C2861: 'int DataComparer::Compare(System::Object ^,System::Object ^)' : an interface member function cannot be defined.

error C3634: 'int DataComparer::Compare(System::Object ^,System::Object ^)' : cannot define an abstract method of a managed class.


Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayList sort collie C# 1 August 28th, 2007 08:08 AM
Ch7 Const Member Functions of a Class proslambano BOOK: Ivor Horton's Beginning Visual C++ 2005 1 March 5th, 2007 05:01 PM
How to Assign a Desc. to a Class Member BrianWren VB.NET 2002/2003 Basics 3 June 1st, 2005 02:07 PM
Invoking event from member variable class adxabuan Visual C++ 0 February 2nd, 2004 06:04 AM
Forum class (member) explination?? drfunkie BOOK: ASP.NET Website Programming Problem-Design-Solution 0 June 15th, 2003 07:46 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.