Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 12-10-2009
Member
 
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.
Reply With Quote
  #2  
Old 12-10-2009
Member
 
Join Date: May 2008
Posts: 2,293
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.
Reply With Quote
  #3  
Old 12-10-2009
Member
 
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.
Reply With Quote
  #4  
Old 12-10-2009
Member
 
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 } };
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Comparison of two classes"
Thread Thread Starter Forum Replies Last Post
Problem with Inner classes Captain Carrot Software Development 5 11-03-2010 02:14 PM
Use of abstract classes ScarFace 01 Software Development 5 25-01-2010 09:07 AM
Sealed Classes in C# Reegan Software Development 5 27-11-2009 09:16 AM
C # using classes in C + + klite Software Development 3 01-10-2009 10:15 AM
Classes in VB.NET Samir_1 Software Development 2 10-04-2009 12:07 AM


All times are GMT +5.5. The time now is 06:39 AM.