I am working on a program that implements a complex number class. I will include the main part of the code. I am getting the following error and can't figure out why.

error C2143: syntax error : missing ';' before 'namespace'

Here is the beginning of the program.

#include "ComplexNumbers.h"
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
	ComplexNumbers number1, number2 (6.5, 9.3);
	ComplexNumbers SumComplexNumbers;
	ComplexNumbers DifferenceComplexNumbers;

	cout <<"Complex numbers default constructor value: " << endl;
	number1.PrintComplexNumbers();
	cout <<"Complex numbers initialized contstructor value: " << endl;
	number2.PrintComplexNumbers();
	SumComplexNumbers = SumComplexNumbers.AddComplexNumbers(number1, number2);
	SumComplexNumbers.PrintComplexNumbers();
	DifferenceComplexNumbers = DifferenceComplexNumbers.SubtractComplexNumbers(number1, number2);
	DifferenceComplexNumbers.PrintComplexNumbers();
	
	return 0;
}

I don't see anything wrong with it, so it's probably in your headerfile (ComplexNumbers.h) . Can you post the code from the header file?

Niek

Here is the header file

class ComplexNumbers
{
   private:
	        double real;
		    double imaginary;

	public:
		    ComplexNumbers();
			ComplexNumbers(double number1, double number2);
			
			void GetNumber();
			double imaginaryPart();
			ComplexNumbers AddComplexNumbers(const ComplexNumbers&, const ComplexNumbers&);
			ComplexNumbers SubtractComplexNumbers(const ComplexNumbers&, const ComplexNumbers&);
			void PrintComplexNumbers();
}

You've missed a semicolon ( ; ) at the very end of the header file

..................
ComplexNumbers&, const ComplexNumbers&);
			void PrintComplexNumbers();
} ; //   <--- voila

Niek

This question has already been answered. Start a new discussion instead.