可能重複:
What is an undefined reference/unresolved external symbol error and how do I fix it?解析的外部符號
我是比較新的C++(因爲你或許可以將問題告訴),我已經打了一個問題。我有兩個文件:Drives.h和Drives.cpp
Drives.h
#pragma once
enum MountMode
{
User,
System,
Both,
Auto
};
class Drive
{
public:
Drive(void);
~Drive(void);
BOOL Mount(MountMode mode);
VOID Unmount(void);
BOOL IsConnected(void);
static char* DeviceName;
static char* DrivePath;
};
class Drives
{
public:
Drives(void);
~Drives(void);
};
和我Drives.cpp:
#include "stdafx.h"
#include "Drives.h"
Drives::Drives(void)
{
Drive USB0; //Error happening here
}
Drives::~Drives(void)
{
}
錯誤是說,驅動器類的構造函數,析構函數和IsConnected()都是未解決的外部問題。我不知道,因爲我設置這個類像上cplusplus.com的一個提前
與其他編譯器不兼容?這實際上讓我發笑。 – Lockhead
@Casey:'#pragma once'在叮噹聲,GCC,Intel,Borland等等時可以正常工作。稱它爲「微軟專用」肯定有點愚蠢。 – ildjarn
@ildjarn:這仍然是非標準的。 – George