F.R.I.E.N.D.S Compiler Error

I wrote a program to compare colors of two shapes. If the colors are same it will display a message informing the colors are same else it will display it is not same. This is my program. It Gives a compiler error.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;

class CTwo; 
//enum clr{green,yellow,red};

class COne
	{
	public:
		COne(string name1):n(name1)
		{
		
		}
		friend void compares(COne,CTwo);//same friend
	private:
		string n;
	};



class CTwo
	{
	public:
		CTwo(string name2):m(name2)
		{
		
		}
		friend void compares(COne,CTwo);//same friend
	private:
		string m;
	};

void compares(COne a,CTwo b)
{
	if((a.n).compare!=(b.m))
		cout<<"Not Matching"<<endl;
	else
		cout<<"Matching"<<endl;

}

int main()
{
	COne j("red");
	CTwo k("red");
	compares(j,k);
	system("PAUSE");
	return 0;
}


These are the errors
1
2
3
Error 1 - too many characters in constant//what does this mean
Error 2 - 'Circle::Circle(std::string)' : cannot convert parameter 1 from 'int' to 'std::string'	//What does this mean
Error 3 - 'strcmp' : cannot convert parameter 1 from 'Circle' to 'const char *'	//what does this mean 


Hope I Will Get Help ... Thank You
Last edited on
Strings should be surrounded with double quotes. Single quotes are for single characters, hence why you are getting the error about "two many characters". The second error is coming from the first, because it is trying to convert the char to an int, and then to a std::string and failing.

The third is because you are using strcmp() to compare your random objects, and you can't do that.
Topic archived. No new replies allowed.