What does a single colon mean in a function title?

B

bpazolli

I've just finished a fairly lengthy "for dummies" book in C++ (the all
in one desk reference edition). So I'm now starting to try and get
into actual programming using wxWidgets through wxDev-C++. Anyhow that
is beside the point I have a function in one of the auto-generated
documents that look like.

frOne::frOne(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
// function stuff
}

I want to know what the wxFrame part means on a general sense. Like I
know frOne is the initialisation member function of the frOne class
but the wxFrame part tagged onto with a single colon I have no idea
what it means in the general structure of things. I'm not asking for a
detail description of the wxFrame function just the basic what it
means when you tag something on like that. If you get what I mean.

Ben Pazolli
 
B

bpazolli

I've just finished a fairly lengthy "for dummies" book in C++ (the all
in one desk reference edition). So I'm now starting to try and get
into actual programming using wxWidgets through wxDev-C++. Anyhow that
is beside the point I have a function in one of the auto-generated
documents that look like.

frOne::frOne(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
       // function stuff

}

I want to know what the wxFrame part means on a general sense. Like I
know frOne is the initialisation member function of the frOne class
but the wxFrame part tagged onto with a single colon I have no idea
what it means in the general structure of things. I'm not asking for a
detail description of the wxFrame function just the basic what it
means when you tag something on like that. If you get what I mean.

Sorry I just realised this is the c group. It's google's fault I
searched for c++ groups and it gave me this. Anyhow if you can answer
my question that would be good otherwise I guess ignore it.

Ben Pazolli
 
B

BartC

Sorry I just realised this is the c group. It's google's fault I
searched for c++ groups and it gave me this. Anyhow if you can answer
my question that would be good otherwise I guess ignore it.

Maybe you should have googled for 'C++ single colon' instead
 
B

bpazolli

bpazolli said:




This is very definitely not C! :)  (I know from your other article
that you realise this now.) Anyway, when you get over to
comp.lang.c++, ask them about constructor initialiser lists.


It means a constructor initialiser list. But if I try to explain it
to you, I'm almost bound to get it wrong, and there may not be
anyone around who knows C++ well enough to correct me, so I really
do suggest that you get yourself over to comp.lang.c++. If you are
using the (abominable) Google Groups portal to Usenet, this link
might help you:

I think I figured it out. It sends the parameters that the class's
initialiser recieved to the parent classes initialiser function as
well (wxFrame). So basically I think colon can be used as a shorthand
to send stuff to another member function. Seems obvious now but you
all know how it is.

Ben Pazolli
 
A

Antoninus Twink

frOne::frOne(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
// function stuff
}

I want to know what the wxFrame part means on a general sense.

In C++, whenever an object is constructed, its parent class(es)'
constructor(s) first need to be called, as well as the constructors for
any objects that belong to the class. By default, these ctors get
invoked with no arguments (the default ctor).

The single colon as above provides an "initialization list" to the
constructor: this lets you use a ctor for a parent class and/or fields
in the object other than the default ctor, and you can pass some of the
arguments provided to your ctor to these other ctors by specifying them
in this list.

This explanation sounds a bit clumsy, but it's really very simple - post
again if you need any clarification.
 
R

REH

I think I figured it out. It sends the parameters that the class's
initialiser recieved to the parent classes initialiser function as
well (wxFrame). So basically I think colon can be used as a shorthand
to send stuff to another member function. Seems obvious now but you
all know how it is.

Not quite. Simplistically, it prefixes a list of constructor calls for
the class' parents, data members, and/or virtual base classes.

REH
 
K

Kenny McCormack

G

Guest

I think I figured it out. It sends the parameters that the class's
initialiser recieved to the parent classes initialiser function as
well (wxFrame). So basically I think colon can be used as a shorthand
to send stuff to another member function. Seems obvious now but you
all know how it is.

It's a lttle more than a "shorthand". Ask again on comp.lang.c++
where they *really* know what they are talking about. Also
read the C++ FAQ and get a book. Learning a language like C++
(or even C) can't really be done via internet post
 
C

CBFalconer

bpazolli said:
I've just finished a fairly lengthy "for dummies" book in C++ (the
all in one desk reference edition). So I'm now starting to try and
get into actual programming using wxWidgets through wxDev-C++.
Anyhow that is beside the point I have a function in one of the
auto-generated documents that look like.

This is comp.lang.c. You want comp.lang.c++. A different
language.
 
C

CBFalconer

Richard said:
CBFalconer said:

No, comp.lang.c++ is a different *newsgroup*, not a different
language. In case you hadn't noticed, by the way, he has already
been redirected to clc++ at least twice.

Thank you for your wise and essential comment.
 
I

Ian Collins

Richard said:
CBFalconer said:


No, comp.lang.c++ is a different *newsgroup*, not a different
language. In case you hadn't noticed, by the way, he has already
been redirected to clc++ at least twice.

Give the bloke a break, he was only 11 and a half hours late this time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top