General question for programmers

General technological topics without their own forum go here

Re: General question for programmers

Post by -Ninjex- on Mon Jan 28, 2013 8:51 pm
([msg=72851]see Re: General question for programmers[/msg])

:: Refers to global scope

However if you use : ::
The first colon : is a indication that what will follow is an initializer list. This can appear in a class's constructor as a way to give that class's data members an initial value before the body of the constructor executes.

A small example

Code: Select all
class Foo {
public:
    Foo() :
        x(3),       // int initialized to 3
        str("Hey!"), // std::string initialized to be the string, "Hey!"
        list(5)    // std::vector<float> initialized with 5 values
    { /* constructor body */ }

private:
    int x;
    std::string str;
    std::vector<float> list;
};


-- Mon Jan 28, 2013 8:53 pm --

I highly suggest just to learn the language, I think you may end up confusing yourself...
If you're not willing to learn, no one can help you. If you're determined to learn, no one can stop you.⠠⠵
The absence of evidence is not evidence of absence.
I can explain it for you, but I can't understand it for you.
User avatar
-Ninjex-
Addict
Addict
 
Posts: 1210
Joined: Sun Sep 02, 2012 8:02 pm
Blog: View Blog (0)


Re: General question for programmers

Post by KthProg on Mon Jan 28, 2013 10:00 pm
([msg=72860]see Re: General question for programmers[/msg])

lol ill be learning it next semester.
at which point i will proceed to confuse myself lol
User avatar
KthProg
Poster
Poster
 
Posts: 219
Joined: Wed Jan 23, 2013 7:06 pm
Blog: View Blog (0)


Previous

Return to General

Who is online

Users browsing this forum: No registered users and 0 guests