Stupid Newbie question

This is a discussion on Stupid Newbie question within the C++ Programming forums, part of the General Programming Boards category; This was originally posted in the C discussion board. I was told to bring it here. My background is a ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    10

    Stupid Newbie question

    This was originally posted in the C discussion board. I was told to bring it here. My background is a Delphi programmer, who did C a very long time ago. Recently, I have started developing software in C for hand held terminals, and it's taking me some getting used to using C again ....

    My question is as follows:

    Yet another stupid question ...

    What does the double colon do in the following function declaration? I have looked at the Borland C++ language reference, and it talks about the "scope access operator", but I don't understand how that applies here ...

    Code:
    bool O_Comms::Init (PORT_TYPE port, COMM_PARAM_STRUCT* psComParam)

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    It means that there is a class O_Comms and Init is its member function. This is how you define member functions (outside the class declaration).

    You need to look up a tutorial on the basics of classes in C++.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    10
    Thanks for your reply.

    I'm not using C++. The devices I am programming for have extremely limited memory (1024 - 4096 k), and dynamic memory allocation is a big no - no for me. The function was given to me as an example.

  4. #4
    The larch
    Join Date
    May 2006
    Posts
    3,573
    You don't need a dynamic memory allocation when creating an instance of a class. It can be on the stack just as a plain C-style struct instance.

    Code:
    class X {...};
    
    int main()
    {
         X x; //this is not dynamically allocated
    }
    Of course, if you are planning to work in C, understanding C++ syntax for classes doesn't seem very relevant.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    10
    Quote Originally Posted by anon View Post
    You don't need a dynamic memory allocation when creating an instance of a class. It can be on the stack just as a plain C-style struct instance.

    Code:
    class X {...};
    
    int main()
    {
         X x; //this is not dynamically allocated
    }
    Of course, if you are planning to work in C, understanding C++ syntax for classes doesn't seem very relevant.
    Thank you very much indeed! I was not aware of your first comment (there is a lot I am not aware of ... ), and it's a very big help to me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid newbie question
    By CompiledMonkey in forum C++ Programming
    Replies: 6
    Last Post: 06-06-2004, 01:32 PM
  2. A very stupid newbie question
    By bradleym in forum C Programming
    Replies: 6
    Last Post: 09-14-2002, 05:08 AM
  3. Stupid Question
    By Labelizm in forum Windows Programming
    Replies: 2
    Last Post: 07-24-2002, 05:59 AM
  4. very newbie question: how to copy files
    By webwesen in forum C Programming
    Replies: 26
    Last Post: 04-25-2002, 04:01 PM
  5. Episode II Return Of the newbie : Website IO Question
    By MagiZedd in forum Windows Programming
    Replies: 1
    Last Post: 10-18-2001, 09:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21