我在写课时遇到问题。
我将定义移至另一个源文件以保持“干净”时发生了问题。
我收到的消息是:
1>------ Build started: Project: 1 projekt - sklep, Configuration: Debug Win32 ------
1> main.cpp
.1funkcje.obj : error LNK2001: unresolved external symbol "class Rachunek Kasa_sklepowa" .(?Kasa_sklepowa@@3VRachunek@@A)
1>metody_r.obj : error LNK2001: unresolved external symbol "class Rachunek Kasa_sklepowa" .(?Kasa_sklepowa@@3VRachunek@@A)
1>C:\Users\Ja\Desktop\Studia\PW\Semestr II\C++\Cwiczenia - klasy,obiekty\Debug\1 projekt - .sklep.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Kasa_Sklepowa
是我在main.cpp中声明为A全局的对象-#pragma once
class Rachunek
{
double saldo_ogolne;
public:
Rachunek() {saldo_ogolne=0;};
~Rachunek();
void transakcja(std::string,std::string,double);
void czysc_zarobki();
};
extern Rachunek Kasa_sklepowa;
void Rachunek::transakcja(string _pes,string co,double ile)
{
bla bla
}
Rachunek Kasa_sklepowa();
int main (int agc, char**argv)
{
...
}
最佳答案
这行:
Rachunek Kasa_sklepowa();
extern Rachunek Kasa_sklepowa;
Rachunek Kasa_sklepowa;
class Rachunek
{
public:
static Rachunek Kasa_sklepowa;
...
Rachunek Rachunek::Kasa_sklepowa;
https://stackoverflow.com/questions/15672916/
相关文章:
compiler-errors - 这怎么了? Submit.CommandText = SQL?
compiler-errors - 在NME中定位-演示项目无法转换为例如JavaScript-目标
php - 在XPath评估之前,如何处理字符串中的双引号?
macos - 在MacOS上编译Irrlicht项目时出现“symbol(s) not found
variables - 无法编译::I don't understand my errors. Mo
compiler-errors - JRE 抛出的 fatal error