function calls funtions (programm wrotten with a class)

Write your question here.
How can i make function ( print() ) calls to functions (isInteger() and isProper())
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  Put the code you need help with here.

#include <iostream>		
#include <stdlib.h>
#include <string>

using namespace std;	
						
//#include "CFraction.h"

class CFraction
{
	private:

	int m_nN ;
	int m_nD ;

	public:

	CFraction();
	void setNumerator(int nN);
	bool setDenomirator(int nD);
	bool isInteger();
	bool isProper();
	void print();
};

CFraction::CFraction()
{
	m_nN = 0;
	m_nD = 1;
}

// setNumerator-Methode(Funktion)
void CFraction::setNumerator(int nN)
{
	//cin>>nN;
	m_nN=nN;

}



// setDenomerator-Methode(Funktion)
bool CFraction::setDenomirator(int nD)
{
	if (nD!=0)
	{
		m_nD=nD;
	return true;
	}
	else
	{
		return false;
	}
}


//isInteger-Methode(Funktion)
bool CFraction::isInteger()
{
	float Bruch=m_nN%m_nD;
	if(Bruch==0)
	{	cout<<m_nN<<"/"<<m_nD<<"  ";
		cout<<"ganzzahlig  ";
		return true;
	}
	else
	{	cout<<m_nN<<"/"<<m_nD<<"  ";
		cout<<"nicht ganzzahlig  ";
		return false;
	}
}


//isProper-Methode(Funktion)
bool CFraction::isProper()
{
	int n ,m;
	n=abs(m_nN);
	m=abs(m_nD);
	if(n<m)
	{
		cout<<"echt"<<endl;
		return true;
	}
	else
	{
		cout<<"nicht echt"<<endl;
		return false;
	}
}


void CFraction::print()
{	

	//cout<<endl<<"Zähler ="<<m_nN<<endl;
	//cout<<"Nenner ="<<m_nD;

}







int main (void)
{
    
	cout << "ubung2 gestarted." << endl << endl;


	CFraction f,Bruch;    // Deklaration ein Bruch und f-Objekt

	// Methoden(Funktionen) aufrufen

	CFraction();
	Bruch.setNumerator(4);
	Bruch.setDenomirator(3);
	//Bruch.isInteger();
	//Bruch.isProper();
	Bruch.print();

	return 0;
}
Like so:
1
2
3
4
5
6
7
8
void CFraction::print()
{	
	if(isInteger())
           do_something;
	if(isProper())
           do_something_else;

}
it works .
thank you coder777 :)
Topic archived. No new replies allowed.