Advertisement
ASP_Volume3 Coding Standards #49884

Function is left value

For anyone who thought that function can only be right value - See this code.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
#include <iostream.h>
int &find(int n);
int vect[10]={0,1,17,2,8,25,32,15,48,5};
int main()
{
	int i;
	for(i=0;i<10;i++)
		cout << vect[i] << " ";
	cout << endl;
	find(25)=100;
	for(i=0;i<10;i++)
 		cout << vect[i] << " ";
	cout << endl;
	return 0;
}
int &find(int n)
{
	int i;
	for(i=0;i<10 && vect[i] != n;i++);
		if(n==vect[i])
			return(vect[i]);
		else
			return(vect[0]);
}
Upload
Upload
Commenti originali (3)
Recuperato da Wayback Machine