using ::

why would using :: (two colons) be neccessary?

ex.) function CloakingPackImage::onMount(%data, %obj, %node)

that is actually out of a game (tribes 2)

hehe
cheers,
eb

Comments

  • : why would using :: (two colons) be neccessary?
    :
    : ex.) function CloakingPackImage::onMount(%data, %obj, %node)
    :
    : that is actually out of a game (tribes 2)
    :
    : hehe
    : cheers,
    : eb
    :
    Its the scope resolution operator - it tells the compiler that this onMount function is a part of the CloakingPackImage class.
  • : : why would using :: (two colons) be neccessary?
    : :
    : : ex.) function CloakingPackImage::onMount(%data, %obj, %node)
    : :
    : : that is actually out of a game (tribes 2)
    : :
    : : hehe
    : : cheers,
    : : eb
    : :
    : Its the scope resolution operator - it tells the compiler that this onMount function is a part of the CloakingPackImage class.
    :

    can you give me an example?

  • : : : why would using :: (two colons) be neccessary?
    : : :
    : : : ex.) function CloakingPackImage::onMount(%data, %obj, %node)
    : : :
    : : : that is actually out of a game (tribes 2)
    : : :
    : : : hehe
    : : : cheers,
    : : : eb
    : : :
    : : Its the scope resolution operator - it tells the compiler that this onMount function is a part of the CloakingPackImage class.
    : :
    :
    : can you give me an example?
    :
    :
    [blue]you already gave an example in your original post. That is C++ coding, not C. You need to study c++ before you can fully understand that.[/blue]

  • : : : : why would using :: (two colons) be neccessary?
    : : : :
    : : : : ex.) function CloakingPackImage::onMount(%data, %obj, %node)
    : : : :
    : : : : that is actually out of a game (tribes 2)
    : : : :
    : : : : hehe
    : : : : cheers,
    : : : : eb
    : : : :
    : : : Its the scope resolution operator - it tells the compiler that this onMount function is a part of the CloakingPackImage class.
    : : :
    : :
    : : can you give me an example?
    : :
    : :
    : [blue]you already gave an example in your original post. That is C++ coding, not C. You need to study c++ before you can fully understand that.[/blue]
    :
    :
    But as further example....
    [code]
    // This would be the declaration of the class and its associated methods and variables
    class CloakingPackImage
    {
    CloakingPackImage();
    ~CloakingPackImage();
    int onMount(DataObject* d, LocalObject* o, Node* n);
    int onDismount(bool Immediate = true);
    // ... additional methods here....

    private:
    DataObject* pData;
    LocalObject* pObject;
    Node* pNode;
    // ... additional internal data variables here ....
    };

    // This would be the definitions of the various class methods.
    // Notice the scope resolution operator that tells the compiler
    // these are the functions associated with the class defined above
    CloakingPackImage::CloakingPackImage()
    { // ctor - constructor is a special method of an object
    pData = NULL;
    pObject = NULL;
    pNode = NULL;
    // do additional initialization stuff here......
    }

    CloakingPackImage::~CloakingPackImage()
    { // dtor - destructor is a special method of an object
    // do destructor stuff here.....
    if (NULL != pData) delete pData;
    // .....
    }

    int CloakingPackImage::onMount(DataObject* d, LocalObject* o, Node* n)
    {
    // do mounting functionality here.....
    pData = d;
    pObject = o;
    pNode = n;
    }

    int CloakingPackImage::onDismount(bool Immediate)
    {
    // do dismounting functionality here.....
    }[/code]
    As pointed out, this is all basic C++ and if you are not familiar with the forms, get a good basic book on C++ to start learning.

  • [RED] yup its one of the several uses of :: operators, to expand the scope of a member method.
    [RED]
  • :[blue] thanks

  • As said by a previous posting the Scope resolution operator is used in c++.

    You could use the scope resolution operator for inheritence

    [code]
    class kodi
    {
    //private members private by default here
    int i = 10;
    public:
    void num(int j){i = j;}//automatic inline function
    int show(){return i;}
    };
    void kodi::num(int j)
    {
    i = j;
    }

    int main()
    {
    kodi x;
    cout<<x.num()<<"results:
    ";
    x.show();
    return 0;
    }
    [/code]

    Please excuse my bad code I was trying to show inheritence and I did an inline function and I could of gone into parameterized functions or something more like pointers but i'm pressed with time and the computer i'm at now doesnt have a compiler for me to correct syntax.

    So yeah the Scope Resolution operator is used in c++. If you have a local public library that has programming books you should get borrow the book. If the book is old it might have the older c++ standard like a book from 1998.

    Bye
    George

    <------------------------------------------>

    Reach me at:

    AIM IM: kc2keo
    EMAIL: kc2keo@yahoo.com

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories