问题描述
嗨!
我有这样的课程:
//界面,仅抽象
class ISession {
}
//实现ISession的常用部分
类Session:public virtual ISession {
public:
Session(Socket * conn);
}
//实现ISession的其余部分
类FTPSession:公共虚拟会话{
public:
FTPSession(Socket * conn);
}
我在编译时遇到这个错误:
g ++ -c -g -Wall -O2 -I。 / include -o src / FTPSession.o src / FTPSession.cpp
src / FTPSession.cpp:在构造函数中`
FTPServer _ :: FTPSession :: FTPSession(FTPServer_ :: Soc ket *)'':
src / FTPSession.cpp:17:错误:没有匹配函数来调用`
FTPServer _ :: Session :: Session(const< ;匿名> **)''
包含/ Session.h:10:错误:候选者是:
FTPServer_: :Session :: Session(const
FTPServer _ :: Session&)
include / Session.h:12:错误:
FTPServer_ :: Session :: Session(FTPServer _ :: Socket *)
make:*** [src / FTPSession.o]错误1
有什么想法吗?
TIA,
-
-------------------- --------------------------------------------
,你的Thomas Zangl - - -
- Freelancer - IT Consulting&软件开发 -
使用Y.A.M.C!现在!在
Hi!
I have a class hierachie like this:
// interface, abstract only
class ISession {
}
// implements common parts of ISession
class Session: public virtual ISession {
public:
Session(Socket* conn);
}
// implements the rest of ISession
class FTPSession: public virtual Session {
public:
FTPSession(Socket* conn);
}
I get this error on compile:
g++ -c -g -Wall -O2 -I./include -o src/FTPSession.o src/FTPSession.cpp
src/FTPSession.cpp: In constructor `
FTPServer_::FTPSession::FTPSession(FTPServer_::Soc ket*)'':
src/FTPSession.cpp:17: error: no matching function for call to `
FTPServer_::Session::Session(const <anonymous>**)''
include/Session.h:10: error: candidates are:
FTPServer_::Session::Session(const
FTPServer_::Session&)
include/Session.h:12: error:
FTPServer_::Session::Session(FTPServer_::Socket*)
make: *** [src/FTPSession.o] Error 1
Any ideas?
TIA,
--
----------------------------------------------------------------
,yours Thomas Zangl - th****@tzis.net - http://www.tzis.net/ -
- Freelancer - IT Consulting & Software Development -
Use Y.A.M.C! now! Get it at http://www.borg-kindberg.ac.at/yamc/
推荐答案
发布您要编译的实际代码。
V
Post the actual code you are trying to compile.
V
我猜测FTPSession的正文或初始化列表有
错误。发布代码。
干杯! --M
I''m guessing that the body or initialization list of FTPSession has the
error. Post the code for that.
Cheers! --M
这里:
#include" FTPSession.h"
#include" StringUtils.h"
#include"参数。 h"
#include" CommandFactory.h"
#include" Socket.h"
#include< iostream>
#include< sstream>
#include< unistd.h>
使用StringUtils _ :: int2str;
命名空间FTPServer_
{
// ------------- -------------------------------------------------- --------------
FTPSession :: FTPSession(Socket * conn)
{
/ *
*:
data_conn_(0),
is_logged_in_(false)
* /
//获取init命令,仅用于向客户端发送220 CPP Server ready
//
start_command_ = CommandFactory: :getInstanc e()。getInit();
required_fd_ = conn _-> getSocket();
//为所有文件系统函数设置jail
//如果可能的话使用current_working_dir否则/ tmp
char * buf = new char [sizeof(char)* PATH_MAX];
if(getcwd(buf) ,PATH_MAX)== 0){
std :: cout<< 无法获取当前工作目录(使用/ tmp
代替)" << std :: endl;
fs_.setRootDirectory(" / tmp");
} else {
std :: string strbuf(buf );
std :: cout<< 将当前工作目录设置为: << strbuf
<< std :: endl;
fs_.setRootDirectory(strbuf);
}
删除buf;
}
.... //需要更多代码?
TIA!
-
- -------------------------------------------------- -------------
,你的Thomas Zangl - - -
- 自由职业者 - IT咨询&软件开发 -
使用Y.A.M.C!现在!在
Here:
#include "FTPSession.h"
#include "StringUtils.h"
#include "Parameter.h"
#include "CommandFactory.h"
#include "Socket.h"
#include <iostream>
#include <sstream>
#include <unistd.h>
using StringUtils_::int2str;
namespace FTPServer_
{
//-----------------------------------------------------------------------------
FTPSession::FTPSession(Socket *conn)
{
/*
* :
data_conn_(0),
is_logged_in_(false)
*/
// get init command, only used to send a "220 CPP Server ready"
// to the client
start_command_ = CommandFactory::getInstance().getInit();
required_fd_ = conn_->getSocket();
// setup the jail for all filesystem functions
// use current_working_dir if possible otherwise /tmp
char* buf = new char[sizeof(char) * PATH_MAX];
if ( getcwd(buf, PATH_MAX) == 0 ){
std::cout << "Cannot get current working directory (using /tmp
instead)" << std::endl;
fs_.setRootDirectory("/tmp");
} else {
std::string strbuf(buf);
std::cout << "Setting current working directory to: " << strbuf
<< std::endl;
fs_.setRootDirectory(strbuf);
}
delete buf;
}
.... // more code needed?
TIA!
--
----------------------------------------------------------------
,yours Thomas Zangl - th****@tzis.net - http://www.tzis.net/ -
- Freelancer - IT Consulting & Software Development -
Use Y.A.M.C! now! Get it at http://www.borg-kindberg.ac.at/yamc/
这篇关于使用虚拟继承编译错误:const< anonymous> **的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!