Need explanation with something

D

Daniel Vukadinovic

Can anyone explain me these things in C++?

1.What is :: used for like in the next case:

if(....
{
...

::eek:ne;

...
}
....

2.Do I understand this right?
void something::something:something(...
Is the last something followed after only one : a subclass?

3.What does this mean?
struct something
{
...
} a; ->> what is this used for?

4.Static, const and mutable
Now I read alot about that but I never really understood when do we use
static, const and mutable with variables? I know const is used when we
don't want the value to be changed, but what's static and mutable? I
would appreciate examples so I could understand it better.
 
V

Victor Bazarov

Daniel said:
Can anyone explain me these things in C++?

1.What is :: used for like in the next case:

if(....
{
...

::eek:ne;

The '::' is a _scope_resolution_ operator. So, it helps resolve
(or override) the scope.
...
}
...

2.Do I understand this right?
void something::something:something(...
.. ^
.. A colon is missing here
Is the last something followed after only one : a subclass?

Impossible to say.
3.What does this mean?
struct something
{
...
} a; ->> what is this used for?

Declares an object of that type.
4.Static, const and mutable
Now I read alot about that but I never really understood when do we
use static, const and mutable with variables? I know const is used
when we don't want the value to be changed, but what's static and
mutable? I would appreciate examples so I could understand it better.

What book are you reading that doesn't explain those?

V
 
D

Daniel Vukadinovic

I know the theory of my problems but I don't know how to use them in
real life.I know a; is a object of that type, but what does that mean?
You know?
I have two my local colledge textbooks and some e-books but I still
don't get it.
 
M

Markus Schoder

Daniel said:
I know the theory of my problems but I don't know how to use them in
real life.I know a; is a object of that type, but what does that mean?
You know?

struct something
{
....
} a;

Is just short for

struct something
{
....
};
something a;

Pure syntactical sugar.
 
J

Jonathan Mcdougall

Daniel Vukadinovic wrote:

Please quote the message you are answering to.
I know the theory of my problems but I don't know how to use them in
real life.I know a; is a object of that type, but what does that mean?

Every object has a type which defines, among other things, the
operations you can do on that object. I strongly recommend

1) browsing the FAQ (http://www.parashift.com/c++-faq-lite/)
2) buying a good book (Accelerated C++ from Koenig and Moo is usually
recommended)
3) starting to actually program, this will help you understand the
"theory of your problems"
I have two my local colledge textbooks and some e-books but I still
don't get it.

Change them. See www.accu.org for suggestions.


Jonathan
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top