இடைமுகம் (பொருள் நோக்கு நிரலாக்கம்)

பொருள் நோக்கு நிரலாக்கத்தில் இடைமுகம் (protocol or interface) என்பது செயலிகளை மட்டும் விபரிக்கும் ஒரு நுண்புல வகுப்பு ஆகும். இடைமுகத்தில் இருந்து மரபியல்புகள் பெறும் வகுப்புக்கள் அந்த செயலிகளை நிறைவேற்ற வேண்டும். நிறைவேற்றும் வகுப்புகளுக்கு விரிவான சுதந்திரம் தேவைப்படும் போது அல்லது நிறைவேற்ற வேண்டிய செயலிகள் பற்றி போதிய தகவல்கள் இல்லாத போது இடைமுகங்களைப் பயன்படுத்தலாம்.

எடுத்துக்காட்டுக்கள்

பி.எச்.பி

<?php

interface Employee
{
	function setdata($empname,$empage);
	function outputData();
}
 
class TestEmployee implements Employee{

	function setdata($empname,$empage)
	{
            //Functionality
	}
 
	function outputData()
	{
		echo "Inside TestEmployee Class";
	}
}
 
$a = new TestEmployee;
$a->outputData();

?>

வெளி இணைப்புகள்

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.