Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have create this Function:

void arith::tp()
{
	int z;
	float x, y;
do
{
cout << endl
<< " 1 -> Addition + \n"
<< " 2 -> Subtraction - \n"
<< " 3 -> Multiplication * \n"
<< " 4 -> Division  / \n"
<< " 5 -> Squared x^2 \n"
<< " 6 -> Calculation 1/x \n"
<< " 7 -> Square Root \n"
<< " 8 -> Per Cent \n"
<< " 0 -> Exit \n"
<< " Give a choice: ";
cin >> z;
......


when choice the 0 i want to return in main
C++
int main()
{
int ep;

do
{
cout << endl
<< " 1 -> Tupikh Xrhsh \n"
<< " 2 -> Epistimonikh Xrhsh \n"
<< " 3 -> Isotimia Nomismatos \n"
<< " 4 -> Thermokrasia \n"
<< " 5 -> Mhkos \n"
<< " 6 -> Varos \n"
<< " 7 -> Xronos \n"
<< " 0 -> Exit \n"
<< " Dwse mia epilogh: ";
cin >> ep;

}
while (ep!=0);
return 0;
}


how can i do this??

What I have tried:

i dont know how to do this thanks
Posted
Updated 4-May-21 11:13am
v2
Comments
Rick York 3-May-21 19:41pm    
It appears to me that you already are returning from main.

Quote:
when choice the 0 i want to return in main

It is exactly what happen.
C++
int main()
	// beginning of main
	int ep;

	do
	{
		cout << endl
		<< " 1 -> Tupikh Xrhsh \n"
		<< " 2 -> Epistimonikh Xrhsh \n"
		<< " 3 -> Isotimia Nomismatos \n"
		<< " 4 -> Thermokrasia \n"
		<< " 5 -> Mhkos \n"
		<< " 6 -> Varos \n"
		<< " 7 -> Xronos \n"
		<< " 0 -> Exit \n"
		<< " Dwse mia epilogh: ";
		cin >> ep;

	}
	while (ep!=0);
	// where you are when you leave the loop
	return 0;
	// end of main
}

You need to explain with more details what you want.
 
Share this answer
 
C++
void arith::tp()
{
  int z;
  float x, y;
  do
  {
    cout << endl
      << " 1 -> Addition + \n"
      << " 2 -> Subtraction - \n"
      << " 3 -> Multiplication * \n"
      << " 4 -> Division  / \n"
      << " 5 -> Squared x^2 \n"
      << " 6 -> Calculation 1/x \n"
      << " 7 -> Square Root \n"
      << " 8 -> Per Cent \n"
      << " 0 -> Exit \n"
      << " Give a choice: ";
      cin >> z;
      // ...
   } while ( z != 0);
  // here the method exits and control returns to the calling code (main)
}
 
Share this answer
 
i dont know how to do this thanks

NoNobody knows what exactly you want to know when you ask for "this".

Just aother guess:
To call a member function you first have to declare the class
C++
// demo1.cpp : Console application
#include <iostream>

class arith {
public:
	void tp();
};

using namespace std;

// Hi i have create this Function:

// Tupikh Xrhsh
void arith::tp()
{
	int z;
	do {
		cout << endl
			<< " 1 -> Addition + \n"
			<< " 2 -> Subtraction - \n"
			<< " 3 -> Multiplication * \n"
			<< " 4 -> Division  / \n"
			<< " 5 -> Squared x^2 \n"
			<< " 6 -> Calculation 1/x \n"
			<< " 7 -> Square Root \n"
			<< " 8 -> Per Cent \n"
			<< " 0 -> Exit \n"
			<< " Give a choice: ";
		cin >> z;
	} while (z != 0);
}

// 	when choice the 0 i want to return in main


The code was already in main, just copy & paste.

C++
int main()
{
	int ep;
	arith run;
	do {
		cout << endl
			<< " 1 -> Tupikh Xrhsh \n"       // stupid Xrnsh
			<< " 2 -> Epistimonikh Xrhsh \n"  // scientific Xrnsh
			<< " 3 -> Isotimia Nomismatos \n"
			<< " 4 -> Thermokrasia \n"
			<< " 5 -> Mhkos \n"
			<< " 6 -> Varos \n"
			<< " 7 -> Xronos \n"
			<< " 0 -> Exit \n"
			<< " Dwse mia epilogh: ";
		cin >> ep;
		switch (ep) {
		case 1:	run.tp();
				break;
		}


	} while (ep != 0);
	return 0;
}

Last thing is to call the memberfunction and job is done.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900