error: no matching function for call to ...

When I run this program this build message appears:
no matching function for call to Alpha::Alpha(Alpha)
Please tell me what's wrong with program.

#include <cctype>
#include <iostream>
using namespace std;
class Alpha{
private:
unsigned bin;
public:
Alpha() {bin=0;};
Alpha(Alpha& y): bin(y.bin){}; //<----candidate
Alpha(char*);
Alpha operator +(Alpha&);
friend ostream& operator << (ostream&, Alpha&);
};
Alpha::Alpha(char* s){ // <---candidate
bin=0;
while(*s){
bin|=(1<<(tolower(*s)-'a'));s++;}
}//Alpha
Alpha Alpha:: operator+(Alpha& y){
Alpha z;
z.bin=bin|y.bin;
return(z);
}//operator+
ostream& operator << (ostream& out,Alpha& z){
unsigned bit=1;
int i;
for(i=0; i<26;i++){
if((z.bin& bit)>0)
out<<(char)('a'+i);
bit=bit<<1;
}
return out;
}//<<
int main (int argc,char* argv[]){
Alpha x(argv[1]);
Alpha y(argv[2]);
Alpha z;
z=x+y; // <---- no matching function for call to Alpha::Alpha(Alpha)
cout<<z;
return (0);
}//main
Last edited on
Change declaration

Alpha(Alpha& y): bin(y.bin){};

to

Alpha(const Alpha& y): bin(y.bin){};
Влад фром Москоу, i tried to change then new error appears: segmentation fault
It might be the result of execution of statements

Alpha x(argv[1]);
Alpha y(argv[2]);

Are you sure that argv[1] and argv[2] are set?

oh, I didn't put arguments! i'm so stupid!
Thank you for your help!
Topic archived. No new replies allowed.