473,386 Members | 1,715 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,386 software developers and data experts.

A basic C++ question

QQ
Hello, I am new on C++, I am reading one source code
ZThread::ZThread(char *threadname):bug("ZThread")
~~~~~~~~~~~~~~~~~~~What does it mean?

Thanks a lot!

{
........
}

Jul 23 '05 #1
5 1107
QQ wrote:
Hello, I am new on C++, I am reading one source code
ZThread::ZThread(char *threadname):bug("ZThread")
~~~~~~~~~~~~~~~~~~~What does it mean?


Which C++ book are you reading that doesn't explain initializer lists? This
is a very basic concept of C++.
The above means that 'bug' is either the name of a base class of ZThread or
the name of one of its data members. In the former case, the base part of
your object is initialized using its constructor that takes a const char*.
In the latter, the data member is initialized with such a constructor.
Without the initializer, the default constructor would be used.

Jul 23 '05 #2
QQ wrote:
Hello, I am new on C++, I am reading one source code
ZThread::ZThread(char *threadname):bug("ZThread")
~~~~~~~~~~~~~~~~~~~What does it mean?

Thanks a lot!

{
.......
}


It's called "initialiser list" ("initializer list"). The member
named 'bug' is initialised with a const char[] argument (a string
literal).

V
Jul 23 '05 #3
It means you've got a method called ZThread in a class called ZThread
(constructor) which take a char pointer as argument and sets the value
of the variable bug to "ZThread".

ZThread::ZThread(char* threadname)
{
bug = "ZThread";
}

This is just another way of writing the (nearly) exact same thing.

Hope this helps!
// eKIK

Jul 23 '05 #4
That looks like a constructor initialization list.

</dib>

Jul 23 '05 #5
"eKIK" <tr***@boreios.net> wrote in message news:11*********************@g49g2000cwa.googlegro ups.com...
It means you've got a method called ZThread in a class called ZThread
(constructor) which take a char pointer as argument and sets the value
of the variable bug to "ZThread".
not "sets the value"; *initialises* bug with ZThread
ZThread::ZThread(char* threadname)
{
bug = "ZThread";
}

This is just another way of writing the (nearly) exact same thing.


Terrible advice... not even "nearly":

1) If bug is declared const it won't compile.

2) If bug is an instance of a class with a constructor taking parameter char* it either won't compile (if bug's class
lacks an assignment operator for char*) or otherwise may not do what you expect it to, since bug's char* constructor
won't be called.

--
Lionel B
Jul 23 '05 #6

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

Similar topics

6
by: pauldepstein | last post by:
I am reading Grimshaw and Ortega's "C++ and Numerical Methods." They construct a vector class which contains the variable vec, a float* variable where the length of the array (number of...
6
by: DH | last post by:
I have a VERY basic question about figuring database size. I've inherited a database which is generally similar to this basic one: Item, Red, Blue, Green, Yellow (text), (int),(int),(int),(int)...
9
by: Malcolm | last post by:
After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter. The question is, how is it most useful? At the moment I have a function int basic(const char *script,...
4
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time...
13
by: Pete | last post by:
I'm cross posting from mscom.webservices.general as I have received no answer there: There has been a number of recent posts requesting how to satisfactorily enable BASIC authorization at the...
5
by: Aussie Rules | last post by:
Hi, Having a mental block on this one. Have done it before but can't rack my brain on how... I have an object, with a bunch on property, and I add that object to a combo box. I want the...
4
by: MikeB | last post by:
I've been all over the net with this question, I hope I've finally found a group where I can ask about Visual Basic 2005. I'm at uni and we're working with Visual Basic 2005. I have some books, ...
1
by: frankhanretty | last post by:
Do I have to install Visual basic on the remote terminals as I did on the server? I have an visual basic 5 application running fine on my client's server and he is now networked. He wants to run the...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
3
by: Scott Stark | last post by:
Hello, I'm trying to get a better handle on OOP programming principles in VB.NET. Forgive me if this question is sort of basic, but here's what I want to do. I have a collection of Employee...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.