Constructor Inheritance, kinda

Posts 1–6 of 6 · Page 1 of 1
Constructor Inheritance, kinda
Hmm another question.
Code:
// friend_functions.cpp
// compile with: /EHsc
#include <iostream>

using namespace std;
class Point
{
    friend void ChangePrivate( Point & );
public:
    Point( void ) : m_i(0) {}
    void PrintPrivate( void ){cout << m_i << endl; }

private:
    int m_i;
};

void ChangePrivate ( Point &i ) { i.m_i++; }

int main()
{
   Point sPoint;
   sPoint.PrintPrivate();
   ChangePrivate(sPoint);
   sPoint.PrintPrivate();
}
This code snippet is from here. Friend Functions (C++)

If you direct your attention to the red you see this
Code:
Point( void ) : m_i(0) {}
What exactly does that mean? At first i thought it was for inheriting the constructor of a class. But then i look down further and see the m_i, is an integer variable and not a class constructor. Thus my confusedness at the moment. Could someone please explain what exactly just occurred back there. Thanks >_<
Oh wow. I don't know what that is either and I just thought I was about finished with my book. xD Way to go find some really obscure function zeco... for a second there I was starting to feel like I actually knew what I was talking about too. :P
No wonder you are always learning when you program. By use i could guess what it did. But i'm not happy until i know exactly what it is and how it works. That is interestingly strange
Is ":" an operator? if so whats it called?
I'm not sure what it's called. I know its usually used for inheriting a base class though :L

This is the :: scope resolution operator, but that doesn't answer your question.
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?