I can't understand this error message.

Recently I've been messing with conversion constructors (or conversion in general) and trying to write some real code VC++ keeps throwing imaginary errors in my face.

Error message:
1
2
syntax error : missing ';' before '.'
syntax error : missing ';' before '.'


Two lines (near the end) related to the error are marked as "ERROR".

The code:
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
#include<iostream>
#include <string>
#include<conio.h>
using namespace std;

class number;

class complex
{
public:
	double real;
	double imaginary;

	complex (double r, double i): real(r), imaginary(i){}

	friend number;
};

class number
{
public:
	double var1;
	double var2;
	
	number (double a, double b): var1(a), var2(b) {}
	number (const complex& ob)
	{
		var1 = ob.real;
		var2 = ob.imaginary;
	}

	friend complex;

	static void show (const number& ob)
	{
		cout<<ob.var1<<" "<<ob.var2;
	}
};

int main()
{
	complex newOne(11,22);  ERROR
	number.show(newOne);  ERROR

	getch();
	return 0;
} 
number::show(newOne);

Also,
friend class number; friend class complex;
Last edited on
Yay! :-) Thank you.
Topic archived. No new replies allowed.