CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: C++ and states

  1. #1
    Join Date
    Feb 2003
    Location
    Pune,INDIA
    Posts
    49

    C++ and states

    hi friends
    Can we say that class/objects in C++ implicitly supports state based programmming?
    Vikrams

  2. #2
    Join Date
    Oct 2005
    Location
    Bangalore
    Posts
    1,051

    Re: C++ and states

    state based programming ???? clarify your question plz
    - Sreehari
    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
    " Everybody is sent to Earth on a purpose. I am so Lagging behind that i won't die." – Calvin

  3. #3
    Join Date
    Feb 2003
    Location
    Pune,INDIA
    Posts
    49

    Re: C++ and states

    well let me explain,
    Say I have a class

    Class SunLight{
    public:
    bool state;
    void set_state(bool state_value)
    {
    state=state_value;
    }
    };

    Here I am have function which changes the data member value of my class. So in general I am changing the state of my class.

    in C language I can do same using procedure programming but where I need to explicly declare and hold/preserve variables and manuipulate by passing those variables to function.I think this extra burden on programmer.

    finally Such kind of implementation can ne implemented as shown above in C++ using classes. So can we say that for state based system my class are useful and efficient, hence the argument "C++ classes implicilty supports state based programming".
    Vikrams

  4. #4
    Join Date
    May 2004
    Location
    London, England
    Posts
    563

    Re: C++ and states

    You are correct.

    Objects, or classes, can hold a particular state, and, I'm probably sticking my neck out here by saying this, but encapsulation, ie. the parts of the class that you wish to hide from other classes, ideally promotes a state based architecture.

    Hope that helps.
    I don't mind that you think slowly but I do mind that you are publishing faster than you think. Wolfgang Pauli, physicist, Nobel laureate (1900-1958)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured