im stuck having issue with class functions

Hi every one,

I am have some issues trying to get this code to work. Im not sure what Im doing wrong. the program is suppose create objects one, two & three under the class Number. assign a value and then display it in integer, us style and eruo style.
(us and euro stlye is the integer converted to string and add punctuation 3 positions in from the end. ( , for US and . for EURO

Header (content between curly brases has been provided and cannot be changed.
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
  # ifndef number_H
#define number_H

#include <string>
#include <sstream>
#include <iostream>

using namespace std;


class Number {
    public:
        // Default constructor without any initial value.
		// Initial value will be set to 0.
        // Value of integer is 0.     
        // Value of US is “0”.
        // Value of EURO is “0”.
        Number();
        
        // Constructor with initial value.
        Number(int);
        
        // Returns int as a string in US style.
        string get_US_style()const;
        
        // Returns int as a string in Euro style.
        string get_EURO_style()const;
        
        // Returns the int.  
        int get_number()const;
        
        // Sets the value of int, US, and EURO.
        void set_number(int); 
        
    private:
        // A decimal number less than 4000.
        int number; 
        
        // A string represent number in US style.
        string US;

        // A string representing number in EURO style.
        string EURO;

        // converting int to string in US style
        void int_to_US();

        // converting int to string in EURO style
        void int_to_EURO();
};  
#endif 

Main.cpp
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
// example: one class, two objects
#include <iostream>
#include <sstream>
#include "number.h"

using namespace std;

int main () {
  Number one, two, three;
  one.number();
  one.set_number (1111);
  int a = one.get_numner;
  one.number(a);
	cout << "Number one: " << endl;
	cout << a << endl;
  /*one.set_number (99);
	cout << "Number one: " << endl;
	cout << one.get_number() << endl;
  two.set_number (22);
	cout << "Number two: " << endl;
	cout << two.get_number() << endl;
  two.set_number(2022);
	cout << "Number two: "<< endl;
	cout << two.get_number() << endl;
  three.set_number(3333);
	cout << "Number three: " <<  endl;
	cout << three.get_number() << endl;*/

	return 0;
}

number.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


#include <string>
#include <sstream>
#include <iostream>
#include "number.h"

using namespace std;
int Number::Number(int);
	string EURO;
	string US;
	

int Number::number()
{
	set_number(0);
	number(get_number)
	return 0;
}


//  convert number to US Style
string Number::get_US_style() {
	return US;
}

// convert number to EURO style.
string Number::get_EURO_style () const
{
	return EURO;

	}
  

int Number::get_numner() const
{	
	return number;
}
// 
void Number::set_number (int a) {
	number = a;
	return 0;
}


//************************************** Private Functions


void int_to_EURO
// convert number to string.
	stringstream b;
	b << number << endl;
	EURO = b.str();
	
	//determine if string length needs punctuation and where to put it.
	int point = 0;	
	if (EURO.length > 3)
	{
		ponit = EURO.length - 3;
	}
	if (point > 1)
	{
		 EURO.insert(point,1,'.'); 
		 

void int_to_US()
// convert number to string.
	stringstream b;
	b << number << endl;
	US =b.str();
	
	//determine if string length needs punctuation and where to put it.
	int point = 0;	
	if (US.length > 3)
	{
		ponit = US.length - 3;
	}
	if (point > 1)
	{
		 US.insert(point,1,','); 
	}		 
When defining a function you need to enclose the code in { }. You have done it for some functions but not for all of them.
Also,
1
2
3
4
5
6
int Number::number()
{
	set_number(0);
	number(get_number) // THIS LOOKS VERY WRONG
	return 0;
}
hi thank you guys.

i have fixed up the problems. it seamed i got lost when coding this. i fixed the errors and cleaned up the code and it works great thank you.

Topic archived. No new replies allowed.