Click here to Skip to main content
15,889,216 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dev C++ cant accept vector?? Pin
Rajesh R Subramanian29-Nov-09 6:54
professionalRajesh R Subramanian29-Nov-09 6:54 
GeneralRe: Dev C++ cant accept vector?? Pin
nuttynibbles29-Nov-09 6:57
nuttynibbles29-Nov-09 6:57 
AnswerRe: Dev C++ cant accept vector?? Pin
Sarath C29-Nov-09 13:27
Sarath C29-Nov-09 13:27 
GeneralRe: Dev C++ cant accept vector?? Pin
nuttynibbles29-Nov-09 18:36
nuttynibbles29-Nov-09 18:36 
GeneralRe: Dev C++ cant accept vector?? Pin
Cedric Moonen29-Nov-09 20:25
Cedric Moonen29-Nov-09 20:25 
GeneralRe: Dev C++ cant accept vector?? Pin
CPallini29-Nov-09 21:11
mveCPallini29-Nov-09 21:11 
GeneralRe: Dev C++ cant accept vector?? Pin
Sarath C29-Nov-09 22:53
Sarath C29-Nov-09 22:53 
AnswerRe: Dev C++ cant accept vector?? Pin
Rajesh R Subramanian30-Nov-09 4:48
professionalRajesh R Subramanian30-Nov-09 4:48 
You keep giving showing your code in bits and pieces. It's very difficult to help you. However, it appears that you're trying to sort a vector such that there are only unique elements. See if this helps:
// Cons.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void UniqueSort(std::vector<string>& MyVec)
{
	sort(MyVec.begin(), MyVec.end());
	MyVec.erase(unique(MyVec.begin(), MyVec.end()), MyVec.end());
}

int _tmain()
{
	vector<string> vec;
	vec.push_back("one"); 
	vec.push_back("two");
	vec.push_back("one");  //duplicate
	vec.push_back("four");
	vec.push_back("five");
	vec.push_back("six");
	vec.push_back("seven");
	vec.push_back("eight");
	vec.push_back("six"); //duplicate

	//cout<<"Before sorting"<<endl;

	int nSize = vec.size(); //9
	
	UniqueSort(vec);
	
	nSize = vec.size(); //7 (2 duplicates removed)

	//cout<<"After sorting"<<endl;

        return 0;
}



“Follow your bliss.” – Joseph Campbell

QuestionNotification of user login Pin
AmitCohen22229-Nov-09 5:00
AmitCohen22229-Nov-09 5:00 
AnswerRe: Notification of user login Pin
«_Superman_»29-Nov-09 6:03
professional«_Superman_»29-Nov-09 6:03 
QuestionHelp with Error Message Pin
cdpace29-Nov-09 2:53
cdpace29-Nov-09 2:53 
AnswerRe: Help with Error Message Pin
cdpace29-Nov-09 2:55
cdpace29-Nov-09 2:55 
GeneralRe: Help with Error Message Pin
Richard MacCutchan29-Nov-09 5:43
mveRichard MacCutchan29-Nov-09 5:43 
Questionstring concat Pin
nuttynibbles28-Nov-09 22:36
nuttynibbles28-Nov-09 22:36 
AnswerRe: string concat Pin
Cedric Moonen28-Nov-09 22:49
Cedric Moonen28-Nov-09 22:49 
AnswerRe: string concat Pin
T210228-Nov-09 22:49
T210228-Nov-09 22:49 
GeneralRe: string concat Pin
nuttynibbles28-Nov-09 23:00
nuttynibbles28-Nov-09 23:00 
AnswerRe: string concat Pin
nuttynibbles28-Nov-09 23:17
nuttynibbles28-Nov-09 23:17 
GeneralRe: string concat Pin
T210228-Nov-09 23:40
T210228-Nov-09 23:40 
QuestionGenerating a TLB file from an IDL file ?(How to use COM DLL) Pin
Kushagra Tiwari28-Nov-09 21:42
Kushagra Tiwari28-Nov-09 21:42 
AnswerRe: Generating a TLB file from an IDL file ?(How to use COM DLL) Pin
Garth J Lancaster28-Nov-09 22:50
professionalGarth J Lancaster28-Nov-09 22:50 
Questioncomputer name, motherboard sn, hard disk sn Pin
mazizi28-Nov-09 18:45
mazizi28-Nov-09 18:45 
AnswerRe: computer name, motherboard sn, hard disk sn Pin
«_Superman_»28-Nov-09 19:22
professional«_Superman_»28-Nov-09 19:22 
GeneralRe: computer name, motherboard sn, hard disk sn Pin
mazizi28-Nov-09 21:31
mazizi28-Nov-09 21:31 
AnswerRe: computer name, motherboard sn, hard disk sn Pin
T210228-Nov-09 22:50
T210228-Nov-09 22:50 

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.