Results 1 to 4 of 4

Thread: Comparison of two classes

  1. #1
    Join Date
    Apr 2009
    Posts
    79

    Comparison of two classes

    My problem is quite hard to explain but I'll try to ask my question clearly:
    I have a class with an attribute PluginWidget type QWidget *
    I try to reimplement the == operator so that we can compare a QWidget * A PluginWidget (_widget is the attribute of PluginWidget) :

    PluginWidget bool:: operator == (nWidget QWidget *) (return _widget == nWidget)


    I then one of PluginWidget @ list, but when I do an @ list:: indexOf (const T & value, int from = 0), I get error... Is that necessary to declare object in class from which they derived.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Comparison of two classes

    The error because the same type for the argument of indexOf that used for the list. On top of that, you have a list filled with PluginWidget you want to compare with QWidget *, you compare pointers and objects.
    Code:
    int * a = new int; 
    * a = 5; 
    b = 5; 
    
    if (a == b) ()
    it makes no sense You should at least be compare addresses (ie retrieve the addresses that are stored in your @ list) or compare objects and therefore not give a pointer in indexOf.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Comparison of two classes

    Difference Between Class & Objects : A class is a definition of an object. It's a type just like int. if once the class is created it remains till the end of the program, we can't made another class with the same name of the previous class.

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Comparison of two classes

    Class is a userdefined datatype with data members and member functions which can be public or privately accessed depending on access specifiers.Class is static. The attributes of a class always remain unchanged. Class and object both are related to each other, without class, object is of no use and without object, class is useless.
    Example :
    Code:
    struct D
    {
      int b;
      double C;
    };
     
    struct E
    {
      int b; 
      double c;
      C c;
    };
     
    // initialize an object of type C with an initializer-list
    C c = { 1, 2 };
     
    // D has a sub-aggregate of type C. In such cases initializer-clauses can be nested
    D d = { 10, 20, { 1, 2 } };

Similar Threads

  1. Problem with Inner classes
    By Captain Carrot in forum Software Development
    Replies: 5
    Last Post: 11-03-2010, 02:14 PM
  2. Use of abstract classes
    By ScarFace 01 in forum Software Development
    Replies: 5
    Last Post: 25-01-2010, 09:07 AM
  3. Sealed Classes in C#
    By Reegan in forum Software Development
    Replies: 5
    Last Post: 27-11-2009, 09:16 AM
  4. C # using classes in C + +
    By klite in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 10:15 AM
  5. Classes in VB.NET
    By Samir_1 in forum Software Development
    Replies: 2
    Last Post: 10-04-2009, 12:07 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,629,561.70446 seconds with 17 queries