Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to convert a CString object to char array in VC++ MFC Pin
Joe Woodbury25-Jan-10 7:42
professionalJoe Woodbury25-Jan-10 7:42 
GeneralRe: How to convert a CString object to char array in VC++ MFC Pin
Joe Woodbury25-Jan-10 7:01
professionalJoe Woodbury25-Jan-10 7:01 
AnswerRe: How to convert a CString object to char array in VC++ MFC Pin
Madan Chauhan25-Jan-10 0:32
Madan Chauhan25-Jan-10 0:32 
Questionquestion hooking virtual table / class functions Pin
nah133724-Jan-10 10:11
nah133724-Jan-10 10:11 
AnswerRe: question hooking virtual table / class functions Pin
Stuart Dootson24-Jan-10 11:54
professionalStuart Dootson24-Jan-10 11:54 
GeneralRe: question hooking virtual table / class functions Pin
nah133724-Jan-10 19:26
nah133724-Jan-10 19:26 
GeneralRe: question hooking virtual table / class functions Pin
Stuart Dootson24-Jan-10 20:40
professionalStuart Dootson24-Jan-10 20:40 
Questioniterator & operator overloading error Pin
khomeyni24-Jan-10 7:19
khomeyni24-Jan-10 7:19 
hello
can anyone help me why this takes errors?

#include <stdio.h>
#include<iostream>
#include<list>
#include<iterator>
using namespace std;
class code_ch{
public:
char ch;
int number;
code_ch(){
ch=NULL;
number=0;
}
code_ch(int n,char ach){
ch=ach;
number=n;
}
friend istream &operator >> (istream &is,const code_ch &C){
cin>>C.number>>C.ch;
return is;
}

friend ostream &operator << (ostream &os,const code_ch &C){

cout<<C.ch<<" number="<<C.number;
return os;
}
bool operator < (code_ch &h2){
if(number<h2.number)
return true;
return false;
}
bool operator > (code_ch &h2){
if(number>h2.number)
return true;
return false;
}
bool operator <= (code_ch &h2){
if(number<=h2.number)
return true;
return false;
}
bool operator >= (code_ch &h2){
if(number>=h2.number)
return true;
return false;
}
bool operator == (code_ch &h2){
if(number==h2.number)
return true;
return false;
}
};
int main(int argc,char **argv){
if(argc==1){
cout<<"you haven't entered a file! exiting..."<<endl;
return 1;
}
list<code_ch>w;
int *a=new int [200];//for saving the number of each ch
for(int i=0;i<200;i++)
a[i]=0;

list<code_ch>::iterator l=w.begin();
cout<<"the list is:"<<endl;
copy(l.begin(),l.end(),ostream_iterator<code_ch>(cout," "));
}



and the error:

[sajad@sajad Desktop]$ g++ c++file.cpp
c++file.cpp: In function ‘std::istream& operator>>(std::istream&, const code_ch&)’:
c++file.cpp:19: error: ambiguous overload for ‘operator>>’ in ‘std::cin >> C->code_ch::number’
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/istream:119: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/istream:123: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/istream:130: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/istream:238: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
c++file.cpp: In function ‘int main(int, char**)’:
c++file.cpp:66: error: ‘struct std::_List_iterator<code_ch>’ has no member named ‘begin’
c++file.cpp:66: error: ‘struct std::_List_iterator<code_ch>’ has no member named ‘end’
AnswerRe: iterator & operator overloading error Pin
Avi Berger24-Jan-10 7:31
Avi Berger24-Jan-10 7:31 
GeneralRe: iterator & operator overloading error Pin
khomeyni24-Jan-10 7:38
khomeyni24-Jan-10 7:38 
GeneralRe: iterator & operator overloading error Pin
Avi Berger24-Jan-10 8:29
Avi Berger24-Jan-10 8:29 
GeneralRe: iterator & operator overloading error Pin
khomeyni24-Jan-10 8:35
khomeyni24-Jan-10 8:35 
GeneralRe: iterator & operator overloading error Pin
khomeyni24-Jan-10 8:51
khomeyni24-Jan-10 8:51 
GeneralRe: iterator & operator overloading error Pin
Avi Berger24-Jan-10 8:55
Avi Berger24-Jan-10 8:55 
GeneralRe: iterator & operator overloading error Pin
khomeyni24-Jan-10 8:58
khomeyni24-Jan-10 8:58 
GeneralRe: iterator & operator overloading error Pin
Avi Berger24-Jan-10 9:10
Avi Berger24-Jan-10 9:10 
GeneralRe: iterator & operator overloading error Pin
khomeyni24-Jan-10 9:23
khomeyni24-Jan-10 9:23 
GeneralRe: iterator & operator overloading error Pin
khomeyni24-Jan-10 9:27
khomeyni24-Jan-10 9:27 
GeneralRe: iterator & operator overloading error Pin
Avi Berger24-Jan-10 9:35
Avi Berger24-Jan-10 9:35 
Questionwhat are these process with user name SYSTEM Pin
Joseph Marzbani24-Jan-10 5:20
Joseph Marzbani24-Jan-10 5:20 
AnswerRe: what are these process with user name SYSTEM Pin
«_Superman_»24-Jan-10 15:53
professional«_Superman_»24-Jan-10 15:53 
QuestionMove "CArchive" file pointer backward. Pin
CODEPC23-Jan-10 8:11
CODEPC23-Jan-10 8:11 
AnswerRe: Move "CArchive" file pointer backward. [modified] Pin
Emilio Garavaglia23-Jan-10 10:42
Emilio Garavaglia23-Jan-10 10:42 
QuestionMessage Removed Pin
23-Jan-10 6:55
CODEPC23-Jan-10 6:55 
QuestionRe: CFile seek backward Pin
David Crow23-Jan-10 7:07
David Crow23-Jan-10 7:07 

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.