Click here to Skip to main content
15,916,030 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: plz urgent!!! Pin
Rajesh R Subramanian15-Mar-08 5:44
professionalRajesh R Subramanian15-Mar-08 5:44 
GeneralRe: plz urgent!!! Pin
marcio kovags15-Mar-08 9:21
marcio kovags15-Mar-08 9:21 
GeneralAdd Project into workspace Error Pin
bala_potty15-Mar-08 4:57
bala_potty15-Mar-08 4:57 
GeneralRe: Add Project into workspace Error Pin
Rajkumar R15-Mar-08 10:07
Rajkumar R15-Mar-08 10:07 
GeneralRe: Add Project into workspace Error Pin
bala_potty16-Mar-08 0:08
bala_potty16-Mar-08 0:08 
AnswerRe: Add Project into workspace Error Pin
Rajkumar R16-Mar-08 21:41
Rajkumar R16-Mar-08 21:41 
GeneralRe: Add Project into workspace Error Pin
bala_potty6-Apr-08 2:18
bala_potty6-Apr-08 2:18 
Questionstd::find [By any chance my question is not clear?] Pin
_808615-Mar-08 4:29
_808615-Mar-08 4:29 
In the below example, I just push some pointers to objects of type myClass into the vector. Previously, When I pushed just the objects as such, the find algo worked with the overloaded "==". But it's now pointers inside the vector. And I want the find algo still to find it, with integer as the passed argument for it. How can I do it?
class myClass
{
public:
	int x;
	int y;
	bool operator == (const int& n)
	{
		cout<<"\nCheck";
		cout<<"\n"<<n<<"\t"<<x;
		return(n==x);
			
	}
	
};

        std::vector<myClass*> vec_myClass;
	myClass* obj = new myClass();
	obj->x=1;
	obj->y=1;
	vec_myClass.push_back(obj);
	myClass* obj2= new myClass();
	obj2->x=2;
	obj2->y=2;
	vec_myClass.push_back(obj2);
	int n=2;
	vector<myClass*>::iterator itr_vec = vec_myClass.begin(); 
	itr_vec	=std::find(vec_myClass.begin(),vec_myClass.end(),n);//Compilation error here. 


<br />
 itr_vec =std::find(vec_myClass.begin(),vec_myClass.end(),n); <br />

Here it's not taking "n" , and I can also guess why isn't taking. It actually expects an overload of == where we pass a pointer to the object itself. Is there anyway I can do it? Just by passing int?

----------------------------
286? WOWW!Blush | :O

modified on Saturday, March 15, 2008 1:37 PM

AnswerRe: std::find [By any chance my question is not clear?] Pin
Rajkumar R15-Mar-08 9:39
Rajkumar R15-Mar-08 9:39 
GeneralRe: std::find [By any chance my question is not clear?] Pin
_808615-Mar-08 17:21
_808615-Mar-08 17:21 
GeneralRe: std::find [By any chance my question is not clear?] Pin
Rajkumar R15-Mar-08 18:00
Rajkumar R15-Mar-08 18:00 
GeneralRe: std::find [By any chance my question is not clear?] Pin
_808615-Mar-08 19:07
_808615-Mar-08 19:07 
GeneralRe: std::find [By any chance my question is not clear?] Pin
Rajkumar R16-Mar-08 22:58
Rajkumar R16-Mar-08 22:58 
GeneralCompilation Firewalls Pin
George_George15-Mar-08 2:57
George_George15-Mar-08 2:57 
GeneralRe: Compilation Firewalls Pin
Maximilien15-Mar-08 3:34
Maximilien15-Mar-08 3:34 
GeneralRe: Compilation Firewalls Pin
George_George15-Mar-08 3:55
George_George15-Mar-08 3:55 
QuestionWindows Services: User account management Pin
tony_Udz15-Mar-08 2:47
tony_Udz15-Mar-08 2:47 
Questionwhy private virtual function? Pin
George_George15-Mar-08 2:11
George_George15-Mar-08 2:11 
AnswerRe: why private virtual function? Pin
Vasudevan Deepak Kumar15-Mar-08 3:03
Vasudevan Deepak Kumar15-Mar-08 3:03 
GeneralRe: why private virtual function? Pin
George_George16-Mar-08 0:01
George_George16-Mar-08 0:01 
AnswerRe: why private virtual function? Pin
Maximilien15-Mar-08 3:36
Maximilien15-Mar-08 3:36 
GeneralRe: why private virtual function? Pin
George_George15-Mar-08 3:54
George_George15-Mar-08 3:54 
GeneralRe: why private virtual function? Pin
Maximilien15-Mar-08 7:15
Maximilien15-Mar-08 7:15 
GeneralRe: why private virtual function? Pin
George_George16-Mar-08 0:16
George_George16-Mar-08 0:16 
AnswerRe: why private virtual function? Pin
Nemanja Trifunovic15-Mar-08 4:38
Nemanja Trifunovic15-Mar-08 4:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.