OK, a single colon follows an access specifier, such as public:
or private: or protected:, right? Are there any other situations in which a single colon : is used?
Printable View
OK, a single colon follows an access specifier, such as public:
or private: or protected:, right? Are there any other situations in which a single colon : is used?
intializer lists in constructors.
off the top of my head
GOTO:something
Inheritance access specifiers.
Code:class a : public b
{
public:
a( ) : x(0)
{
label:
++x;
if(x < 4)
goto label;
(x > 3) ? x = 2 : x = 1;
}
private:
int x;
};
Accessing a static member of a class: ios_base::hex.
Single colon. Thats two. ;)Quote:
Originally posted by XSquared
Accessing a static member of a class: ios_base::hex.
I need to pay more attention :p.
Conditionals:
Condition ? TruePart : FalsePart
Bah! No I gotta change my example. :)
:)Code:cout<<"Enter a number:";
Most people tend to have only a single colon...
And the most obvious:
So don't make me get on your case about it!Code:switch( foo )
{
case 1:
cout <<"Hey, you forgot about me!" << endl;
break;
default:
cout << "Yeah!" << endl;
}
Quzah.