使用虚拟继承编译错误:const< anonymous> ** [英] Compile error with virtual inheritance: const <anonymous>**
问题描述
嗨!
我有这样的课程:
//界面,仅抽象
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 - th****@tzis.net - http://www.tzis.net/ -
- Freelancer - IT Consulting&软件开发 -
使用Y.A.M.C!现在!在 http://www.borg-kindberg.ac.at/获取yamc /
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/
推荐答案
Thomas Zangl写道:
Thomas Zangl wrote:
我有一个像这样的班级:
//界面,仅抽象
类ISession {
}
;
//实现ISession的常用部分
class Session:public virtual ISession {
public:
Session(Socket * conn);
}
;
//实现其余的ISession
类FTPSession:公共虚拟会话{
公共:
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 *)'':
''FTPServer_''是你忘记提及的命名空间?
构造函数的代码在哪里?
src / FTPSession.cpp:17:错误:没有匹配函数来调用`
FTPServer _ :: Session :: Session(const< anonymous> **)''
include / Session.h:10:错误:候选者是:
FTPServer _ :: Session :: Session(const
FTPServer _ :: Session&)
include / Session.h:12:错误:
FTPServer _ :: Session :: Session(FTPServer _ :: Socket *)
make:*** [ src / FTPSession.o]错误1
任何想法?
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*)'':
Is ''FTPServer_'' a namespace you forgot to mention?
Where is the code for the constructor?
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?
发布您要编译的实际代码。
V
Post the actual code you are trying to compile.
V
Thomas Zangl写道:
Thomas Zangl wrote:
嗨!
我有一个班级hierachie像这样:
//界面,仅抽象
类ISession {
}
//实现ISession的常见部分
class Session:public virtual ISession {
public:
Session(Socket * conn);
}
//实现其余的ISession
类FTPSession:公共虚拟会话{
公共:
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< anonymous> **)''
include / Session.h:10:错误:候选人是:
FTPServer _ :: Session :: Session(const
FTPServer_ ::会话&)
include / Session.h:12:错误:
FTPServer _ :: Session :: Session(FTPServer _ :: Socket *)
make:*** [src / FTPSession.o ]错误1
任何想法?
TIA,
-
---------------- ------------------------------------------------ <无线电通信你的托马斯·赞尔 - th****@tzis.net - http://www.tzis.net/ -
- 自由职业者 - IT咨询&软件开发 -
使用Y.A.M.C!现在!在 http://www.borg-kindberg.ac.at/获取yamc /
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/
我猜测FTPSession的正文或初始化列表有
错误。发布代码。
干杯! --M
I''m guessing that the body or initialization list of FTPSession has the
error. Post the code for that.
Cheers! --M
Victor Bazarov写道:
嗨!
Victor Bazarov wrote:
Hi!
''FTPServer_''是你忘了提到的命名空间吗?
是 - 抱歉。
构造函数的代码在哪里?
Is ''FTPServer_'' a namespace you forgot to mention?
Yes - sorry.
Where is the code for the constructor?
这里:
#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 - th **** @ tzis.net - http://www.tzis.net/ -
- 自由职业者 - IT咨询&软件开发 -
使用Y.A.M.C!现在!在 http://www.borg-kindberg.ac.at/获取yamc /
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> **的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!