希望指点错在哪里,应该要如何样改
希望指点错在哪里,应该要怎么样改?
interface PCI{
function ShowDiveceName();
}
class SoundAdaper implements PCI{
function ShowDiveceName(){
echo "SoundAdaper
";
}
}
class NetworkAdaper implements PCI{
function ShowDiveceName(){
echo"NetworkAdaper
";
}
}
class DisplayAdaper implements PCI{
function ShowDiveceName(){
echo"DisplayAdaper
";
}
}
class Mainboard{
private $PciDevice;
function plug($PciDevice){
$this->PciDevice=$PciDevice;
}
function PCI(){
$this->PciDevice->ShowDeviceName();
}
}
class Engineer{
function Work($Main,$PciDevice){
$Main->plug($PciDevice);
//Fatal error: Call to a member function plug() on a non-object in C:\wamp\www\class_class.php on line 39
//不太明白$Main->plug($PciDevice);这错在哪里
}
}
$sound = new SoundAdaper();
$video = new DisplayAdaper();
$net = new NetworkAdaper();
$main = new MainBoard();
$people = new Engineer();
$people->Work($Main,$SoundAdaper);
$main->PCI();
$people->Work($Main,$DisplayAdaper);
$main->PCI();
$people->Work($Main,$NetworkAdaper);
$main->PCI();
?>
------解决方案--------------------
另外 $SoundAdaper、$DisplayAdaper、$NetworkAdaper 在哪里赋值的?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Computer main represents the main menu or main category in computer software. Some desktop software will have a main menu, including basic operation menus, named main; and in high-level languages such as development languages java and c language, there will be a main class, which is the entrance to program execution. A program can have multiple functions, but there can only be one main() function.

Function means function. It is a reusable code block with specific functions. It is one of the basic components of a program. It can accept input parameters, perform specific operations, and return results. Its purpose is to encapsulate a reusable block of code. code to improve code reusability and maintainability.

The Linux kernel has a main function; the main function is the entry point of the program, and main is an interface name agreed between the application and the operating system, so the first function of each application in Linux must be main.

MAIN is the main antenna interface, and aux is the auxiliary antenna interface; most Intel wireless network card motherboards only have numbers 1, 2, and 3. The main number identified is 1 (connected to the gray line), and the aux number is 2 (connected to the black line). If there are 3, usually connect the white line.

In this article, we will learn about enumerate() function and the purpose of “enumerate()” function in Python. What is the enumerate() function? Python's enumerate() function accepts a data collection as a parameter and returns an enumeration object. Enumeration objects are returned as key-value pairs. The key is the index corresponding to each item, and the value is the items. Syntax enumerate(iterable,start) Parameters iterable - The passed in data collection can be returned as an enumeration object, called iterablestart - As the name suggests, the starting index of the enumeration object is defined by start. if we ignore

Detailed explanation of the role and function of the MySQL.proc table. MySQL is a popular relational database management system. When developers use MySQL, they often involve the creation and management of stored procedures (StoredProcedure). The MySQL.proc table is a very important system table. It stores information related to all stored procedures in the database, including the name, definition, parameters, etc. of the stored procedures. In this article, we will explain in detail the role and functionality of the MySQL.proc table

The general way of writing the main function is as follows: publicstaticvoidmain(String[]args){…} The functions of these keywords are explained below: (1) public keyword, this is easy to understand. Declaring the main function as public tells other classes that they can access this function. (2) The static keyword tells the compiler that the main function is a static function. That is to say, the code in the main function is stored in the static storage area, that is, this code already exists after the class is defined. If the main() method does not use the static modifier, then there will be no error in compilation, but if you try to execute the program, an error will be reported, prompting

Why must main function be forced as the entry point? These languages are compiled languages, which require the code to be compiled into executable binaries. In order for the operating system/bootloader to find the beginning of the program, such a function needs to be defined. In short, you need to define a crucial beginning in a large amount of executable code. It is not difficult to see that for these languages, the main function is an indispensable component. However, when we turn our attention to Python, we will find that the situation is very different. Python is an interpreted language, a scripting language. The running process is performed from top to bottom, line by line, which means that its starting point is known. Each .py file is an executable file and can be used as the entry file for the entire program, meaning
