Help with CONSTRUCTOR

Write your question here.

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
52
53
54
55
56
57
58
#include "functions.h"
#include <iostream>
#include <iomanip>
using namespace std;

diameter::diameter() {	//constructor sets variables to their value
    diameter::pi = 3.141592654;
    diameter::F = 3; 
    diameter::P = 65000; 
    diameter::e = 1;
    diameter::E = 30000000;
    diameter::L = 45;
    diameter::stress=0.0;

	cout << "Welcome to Diamenter//Stress Calculator!\n";
    }

double diameter::getDiameter(double input){		//calculate maximum stress & diameter
	A = (pi*pow(input,2))/4;
    c = input/2;
    i = input/4;
    secantEquation = (L/(2*i))*sqrt((F*P)/(A*E));

    stress = ((F*P)/(A))*(L+(((e*c)/pow(i,2))*(1/cos(secantEquation))));
    return stress;
}

double diameter::validateData()		//validates user input Ex. numerical
{
	double x;

	while (!(std::cin >> x))
		{
			std::cin.clear();
			std::cin.ignore(2000,'\n');
			std::cout << "Please enter a valid number\t" << std::endl;
		}
	return x;
}

double diameter::setDiameter(double calculate){
	
		std::cout << "";
		std::cin >> calculate;
		
		decrement = 50;

		std::cout <<"\nEnter precision desired: ";
		std::cin >> calculate;

		do{
			decrement -= calculate;
			stress = getDiameter( decrement );

		} while(stress <= 50000);

			/*cout << setw(30)<<" "<<"Diameter = "<< decrement << setw(30)<<  "Stress = " << stress << endl;*/
}


The error displays as follows
1> functions.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocmon(16): error C2143: syntax error : missing ';' before 'namespace'
1> Generating Code...

any help is much appreciated !!!
I'd guess that there's something wrong in your #include "functions.h" . Maybe it lacks a '}' or a ';' is missing somewhere
Visual studio need this #include "stdafx.h" to compile..
Last edited on
Here is my finctions.h,
JohnJH my visual studios wont let me add the "stdafx.h" header in my program, it gives me an error so probably it has something to do with the constructor or header.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//function headers
#include <iostream>

class diameter
{
public:
	diameter();
	void setDiameter();
	double getDiameter(double);
	double validateData();
private:
	double pi;
	double result;
	double stress;
	double F;
	double P;
	double A;
	double e;
	double c;
	double i;
	double E;
	double L;
	double secantEquation;
}
Hey guys I could finally built my solution, I just noticed I am missing a ";" at the bottom brace of the header, I will keep you guys posted!

Thanks a lot !
Topic archived. No new replies allowed.