描述中提到的代码的未解析的外部符号

时间:2016-12-02 10:53:00

标签: c++ oop static

 #include <iostream>
class t1
{
public:
    ~t1();
    static t1& fun();
private:
     t1()
     { 
     }
};

t1& t1::fun()
{
    return t1();
}

int main()
{
    t1::fun();
    return 0;
}

我得到了未解析的外部符号。请帮忙。错误低于

Error  2   error LNK2019: unresolved external symbol "public: __thiscall t1::~t1(void)" (??1t1@@QAE@XZ) referenced in function "public: static class t1 & __cdecl t1::fun(void)" (?fun@t1@@SAAAV1@XZ)  D:\LXI\LXIRef\RefDesign_V01.00\Software\Solution\TestWebServer\TestWebServer.obj    TestWebServer
Error   3   error LNK1120: 1 unresolved externals   D:\LXI\LXIRef\RefDesign_V01.00\Software\Solution\Debug\TestWebServer.exe    1   1   TestWebServer

1 个答案:

答案 0 :(得分:1)

给构造函数和析构函数赋予定义。

public Clientes() {


    initComponents();


     LigacaoBD ligaDB = new LigacaoBD();
     Connection con = ligaDB.obterLigacao();

     String query=null;
     Statement xpto;


    try {
        xpto = con.createStatement();

        query = "SELECT cod_postal, localidade FROM codigospostais";
     ResultSet rs = xpto.executeQuery(query);
     while (rs.next()){

         jtcpostal_cliente.addItem(rs.getString(1));


         jtfcodpostal_cliente.setText(rs.getString(2));
         jtfcodpostal_cliente.validate();





        }
    } catch (SQLException ex) {
        Logger.getLogger(Clientes.class.getName()).log(Level.SEVERE, null, ex);
    }



}