Is it possible to call a void function from another void function?

will this work?

mainMenu()
{
 int input;
	cout<<"\t\t  Main Menu \n\n";
	cout<<"\t\t 1. Student Details \n";
	cout<<"\t\t 2. Payment Details \n";
	cout<<"\t\t 3.Exit \n\n";
	cout<<"\t\t Select 1/2/3 : ";
	cin>>input;

    	if(input==1)
	{
	   void studentDetails();
	}  
	if(input==2)
	{
	   void printPaidStudents();
	}
	if(input==3)
	{
	   return -1;
	}
	

}

i wrote the voide studentDetails function too...
but the output is not there...
wats wrong in this?

Recommended Answers

All 9 Replies

i dunno but it's not working..
can i share the whole code?

You're trying to declare functions in mainMenu, not calling them. You don't need to declare the type while calling it.

dont write return type (void,int,....) when u r calling functions.

void mainMenu()
void studentDetails();

Add red void. Function header needs the return type.
Delete green void. Function calls DO NOT need the return type.

MosaicFuneral beat me to it!
Edit : So did Majestics.

i removed the void infront of the function. but now a compilation error came mentioning the function should have a prototype

you have to declare functions before using them,,

return type  function name (parameters list)

in your case

void studentDetails();

and call them

studentDetails();

Because you forgot to declare it outside before hand, such as in a header or where-ever.

Because you forgot to declare it outside before hand, such as in a header or where-ever.

yea. thanx for da help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.