Thread: objects

  1. #1
    I'm less than sure.... abyssphobia's Avatar
    Join Date
    Aug 2004
    Posts
    112

    Post objects

    Ok sombody please, can expain in clear terms what is , and how it works????
    the book said that its created by the user ??? mmm but I still confused.

    Ill be so grateful
    Thx in adv.
    regards,
    Abyss.
    Last edited by abyssphobia; 08-17-2004 at 08:49 PM. Reason: because i didnt finished writting my question
    Have I crossed the line?

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    objects are just what objects are. Like a pen is an object. so if you wanted to make a pen class you would do something like this
    Code:
    class pen
    {
      public:
        void setInk(const int setInkAmount);
         int getInk();
         void penClick();
      private:
         int inkAmount;
    }
    All you have to think about for objects is what really real world object can do and some comptuer object too
    Woop?

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    40
    A collection of variables and functions, pretty much...
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    C++ is an Object-Oriented language. That means that it gives a lot of support for thes collection of data and functions. You can define a type of object, make "instances" of those object, have certain objects inherit properties from others, etc... It's lots of fun...

  5. #5
    Useless Apprentice ryan_germain's Avatar
    Join Date
    Jun 2004
    Posts
    76
    so a class is "like" a type (e.g. int, float, double) and an object is "like" a variable. So you would declare (make an instance ... whatever) an object like so:
    Code:
    MyClasse myObject
    which is "like" saying:
    Code:
    myType myVariable
    another example with classes and objects:
    Code:
    pen this_is_now_a_pen
    Last edited by ryan_germain; 08-18-2004 at 06:37 AM.
    There is not the slightest indication that [nuclear energy] will ever be obtainable. It would mean that the atom would have to be shattered at will.

    -Albert Einstein, 1932

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. most efficient way to write filestream objects?
    By darsunt in forum C++ Programming
    Replies: 3
    Last Post: 01-26-2009, 05:17 PM
  2. Replies: 60
    Last Post: 12-20-2005, 11:36 PM
  3. Question about cout an stack object?
    By joenching in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2005, 10:10 PM
  4. chain of objects within pop framework help needed
    By Davey in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2004, 10:01 AM
  5. array of objects?
    By *~*~*~* in forum C++ Programming
    Replies: 4
    Last Post: 05-31-2003, 05:57 PM