Re: Base class and a advanced case theirs of using
Miros?aw Makowiecki wrote:
We has this one class:
class Socket
{
public:
Socket(Socket&);
};
and it's two class
class Buffer:private Socket
{
public:
Buffer(Socket&soc):Socket(soc){}
Buffer(Buffer const&buf):Socket(/*i co dalej*/){};
};
We have it's code
Socket soc;
Buffer buf1(soc);
Buffer buf2=buf1;
That is a class of socket it has to be common for this objekt of
variable buff1 and buff2,that is their take up a common memory(it's
property of object of Socket).
Question:What have it got to be to a code it was a correct code of C++
language?
As I understand the question, you suspect that the code [you posted]
is somehow incorrect from C++ point of view. Well, the only thing I
can see is that the second constructor of 'Buffer' attempts to
default-initialise the 'Socket' base class, which has no default
c-tor. There is no way to fix that easily without knowing why the
'Socket's constructor needs a reference to non-const. Perhaps it
could take a reference to const, in which case you can write the
second 'Buffer' c-tor as
Buffer(Buffer const &buf) : Socket(buf) {}
.. Of course, it would help immensely if you posted real code.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask