Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Visual C++/MFC/WTL > Подключить класс к пректу?


Автор: Alca 26.6.2008, 12:19
Создал свой класс, подключил хедер в main.cpp:
Код

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <iostream.h>
#include "smtpconnection2.h"

int main() {
    CMimeMessage msg;
    msg.SetSender("...");
    //...
}

Код

//smtpconnection2.h
#pragma once
#include <atlsmtpconnection.h>
#include <Windns.h>
#pragma comment(lib,"Dnsapi.lib")

class CSMTPConnection2 : public CSMTPConnection {
    public:    
        BOOL Connect(LPCTSTR lpszHostDomain, DWORD dwTimeout = 10000) throw();
    private:
        void _GetSMTPList(LPCTSTR lpszHostDomain, CSimpleArray<CString>& arrSMTP);
};


Код

main.obj : error LNK2019: unresolved external symbol "public: int __thiscall CSMTPConnection2::Connect(char const *,unsigned long)" (?Connect@CSMTPConnection2@@QAEHPBDK@Z) referenced in function _main

Автор: Fazil6 26.6.2008, 12:23
ну включи еще и cpp в проект

Автор: Alca 26.6.2008, 12:35
template class are not Type, based on the parameter passed to the template class, C++ compiler would try to create a new type. Since the compiler is lazy it does not get the implementation of the functions exposed in the template class.
Typically you endup inlining the methods of the template class.
If you do not want to inline these methods add the following include statement at the end of the template class defination.
Код

#include "<cpp file name>"

Код

#include "smtpconnection2.cpp"    //вместо #include "smtpconnection2.h"



Автор: Fazil6 26.6.2008, 12:48
мда.... уж решил так решил....

Автор: Lazin 26.6.2008, 13:00
меню проекта (правая кнопка в солюшн эксплорере) -- AddExcistingItem -- выбираешь свой срр файл

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)