473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Base class and a advanced case theirs of using

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?
Thanks in advance.
Mirosław Makowiecki
Jul 7 '07 #1
1 1189
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
Jul 9 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Paul | last post by:
In real life situation, do we ever come across a situation where we would need two base objects in an object. A snippet is worth 1000 words (: so... class Base { }; class Derived1:public Base...
1
by: ypjofficial | last post by:
Dear All, According to OOPs , a base class pointer can to point to derived class object....call this as fact1 But somehow I am not comfortable while understanding this concept. The explanaition...
27
by: tuvok | last post by:
Is it correct that the virtual dtor of base gets called implicitly? Here's some code to demonstrate what I mean: Class B has a virtual destructor, so has class D which is derived from B. Deleting...
15
by: jon | last post by:
How can I call a base interface method? class ThirdPartyClass :IDisposable { //I can not modify this class void IDisposable.Dispose() { Console.WriteLine( "ThirdPartyClass Dispose" ); } } ...
6
by: Taran | last post by:
Hi All, I tried something with the C++ I know and some things just seem strange. consider: #include <iostream> using namespace std;
5
by: Dennis Jones | last post by:
Hello, I have a couple of classes that look something like this: class RecordBase { }; class RecordDerived : public RecordBase {
10
by: Michael D. Ober | last post by:
I have a class: Private Class ClientList Inherits StringCollection Public InternalUser As Boolean = False Public Shadows Function Contains(ByVal ClientNumber As String) As Boolean
6
by: bryanbabula | last post by:
I have a question about overriding i was wondering if anyone could help me with, or even suggesting a better/different way. I have no idea if this can even be done or not. I was wondering if there...
3
by: Rick | last post by:
One of the rules I have recommended for our new coding standard is as follows: "When overriding a base class virtual function, all overloads of that base class virtual function should also be...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.