C++ 架构x86_64的未定义符号。什么';我的密码怎么了?

C++ 架构x86_64的未定义符号。什么';我的密码怎么了?,c++,class,C++,Class,设备.h文件 #ifndef DEVICES_H #define DEVICES_H class malfunctionRecord { private: int Num_Malfunction_Detection; int Type_Malfunction; int Last_Malfunction; public: malfunctionRecord(); void malfunction(int mlfn,int tm); void display();

设备.h文件

#ifndef DEVICES_H
#define DEVICES_H

class malfunctionRecord
{
private:
int Num_Malfunction_Detection;
int Type_Malfunction;
int Last_Malfunction;

public:
    malfunctionRecord();
    void malfunction(int mlfn,int tm);
    void display();
    int getRecord(int*m,int*t);

};

class device
{
private:
    char *Name;
    malfunctionRecord malfunctionRec;
    int Serial_Num;
    int Value_Device;

public:
    device(char*n,int sn);
    ~device();
    void display();
    void recordMalfunction(int m,int t);
    int getMalfunctionRecord(int *m,int *t);
    int amIThisDevice(char*n);

};

#endif

(这是my devices.cpp文件)


当我编译它时,我不断得到以下错误:

g++ devices.cpp main.cpp -o a
devices.cpp:9:23: warning: character constant too long for its type
main.cpp: In function ‘int main()’:
main.cpp:11: warning: deprecated conversion from string constant to ‘char*’
main.cpp:11: warning: deprecated conversion from string constant to ‘char*’
main.cpp:53: warning: deprecated conversion from string constant to ‘char*’
main.cpp:56: warning: deprecated conversion from string constant to ‘char*’
main.cpp:76: warning: deprecated conversion from string constant to ‘char*’
Undefined symbols for architecture x86_64:
  "device::device(char*, int)", referenced from:
      _main in cc7F618W.o
  "device::display()", referenced from:
      _main in cc7F618W.o
  "device::amIThisDevice(char*)", referenced from:
      _main in cc7F618W.o
  "device::recordMalfunction(int, int)", referenced from:
      _main in cc7F618W.o
  "device::getMalfunctionRecord(int*, int*)", referenced from:
      _main in cc7F618W.o
  "device::~device()", referenced from:
      _main in cc7F618W.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

有人能告诉我我的密码有什么问题吗?谢谢

您注释掉了
devices.cpp
中的一系列函数定义(底部的五个)。他们还在头球

这是链接器抱怨您通知它一个符号,然后不定义它


要么定义函数,要么删除对它们的所有引用。

在编写成员函数的实现时,我不确定是否为FailFunctionRecord::getRecord(intm,intt)正确编写。有人能帮我更正代码吗?谢谢
#include "definitions.h"
#include "devices.h"
#include <iostream>

using namespace std;


int main() {

malfunctionRecord m1, m2;
device d1("Turn Signal Lever", 195), d2("Accelerator", 247), *d3;
int c, m, t;          // Temp variables to hold values retrieved from getRecord.
char ch;              // Used to hold display until user presses enter.

// malfunctionReport tests.
cout << "Initially both m1 and m2 should have no malfunctions:\n\n";
m1.display();
cout << "\n";
m2.display();
cout << "\n";

// Set a malfunction in m1.
m1.malfunction(MALFUNCTION_UNDER_RANGE,10);
cout << "m1 should now have one malfunction with time 10 and under range.\n";
m1.display();
// Now add some malfunctions and verify that only the last is kept.
m1.malfunction(MALFUNCTION_OVER_RANGE,25);
cout << "\nm1 should now have two malfunctions, the last one with time 25 and over range.\n";
m1.display();
m1.malfunction(MALFUNCTION_STOPPED_WORKING,32);
cout << "\nm1 should now have three malfunctions, the last one with time 32 and stopped working.\n";
m1.display();

// Now test the retrieval function.
c = m1.getRecord(&m, &t);
cout << "\n\nValues returned from getRecord are " << c << ", " << m << ", and " << t << ".\n";
cout << "\nEnd of malfunctionReport tests.\n\n\n";

// Hold display so user has a chance to check results so far.
cout << "Press ENTR when ready to continue:";
ch = cin.get();



// device class tests.
cout << "\n\n\nBeginning tests for device class.\n";
cout << "Display original d1 and d2:\n\n";
d1.display();
cout << "\n";
d2.display();
cout << "\n\nTest the amIThisDevice function.  \n";

if(d1.amIThisDevice("Turn Signal Lever"))  cout << "  First test on d1 passed.\n";
else                                       cout << "  First test on d1 failed.\n";

if(d1.amIThisDevice("Accelerator")==0)     cout << "  Second test on d1 passed.\n";
else                                       cout << "  Second test on d1 failed.\n";

cout << "\n\nNow test record and get malfunction function members.\n";
d1.recordMalfunction(MALFUNCTION_UNDER_RANGE,25);
cout << "  Should see count equal 1 and under range malfunction at time 25:\n";
d1.display();
d1.recordMalfunction(MALFUNCTION_OVER_RANGE,50);
cout << "\n  Should see count equal 2 and over range malfunction at time 50:\n";
d1.display();
d1.recordMalfunction(MALFUNCTION_STOPPED_WORKING,64);
cout << "\n  Should see count equal 3 and stopped working malfunction at time 64:\n";
d1.display();
cout << "\n\nTry to retrieve malfunction report.  Should see same values as above.\n";
c = d1.getMalfunctionRecord(&m,&t);
cout << "Values returned from getRecord are " << c << ", " << m << ", and " << t << ".\n";

// Test destructor.  Create a new device and then delete it.
cout << "\n\nTesting create and destroy n object.  If you don't see the";
cout << "\nend of tests message, there is something wrong with your destructor.\n\n";
d3 = new device("Temporary Device", 100);
d3->display();
delete d3;


cout << "\n\nEnd of tests for Program 3.\n";


return 0;
}
#define NO_MALFUNCTION                                   20
#define MALFUNCTION_OVER_RANGE                           21
#define MALFUNCTION_UNDER_RANGE                          22
#define MALFUNCTION_STOPPED_WORKING                      23
g++ devices.cpp main.cpp -o a
devices.cpp:9:23: warning: character constant too long for its type
main.cpp: In function ‘int main()’:
main.cpp:11: warning: deprecated conversion from string constant to ‘char*’
main.cpp:11: warning: deprecated conversion from string constant to ‘char*’
main.cpp:53: warning: deprecated conversion from string constant to ‘char*’
main.cpp:56: warning: deprecated conversion from string constant to ‘char*’
main.cpp:76: warning: deprecated conversion from string constant to ‘char*’
Undefined symbols for architecture x86_64:
  "device::device(char*, int)", referenced from:
      _main in cc7F618W.o
  "device::display()", referenced from:
      _main in cc7F618W.o
  "device::amIThisDevice(char*)", referenced from:
      _main in cc7F618W.o
  "device::recordMalfunction(int, int)", referenced from:
      _main in cc7F618W.o
  "device::getMalfunctionRecord(int*, int*)", referenced from:
      _main in cc7F618W.o
  "device::~device()", referenced from:
      _main in cc7F618W.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status