arrays classes and pointers

This is a discussion on arrays classes and pointers within the C++ Programming forums, part of the General Programming Boards category; i need help with three things cause i totally dont get them.the things are string classes and arrays.if anyone can ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    5

    Question arrays classes and pointers

    i need help with three things cause i totally dont get them.the things are string classes and arrays.if anyone can help me out cause ive tried a buncha tutorials and books i always get stuck here so if anyone can help it would be appreciated.Oh yea and please dont get to technical.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    4
    /* Edited by Mod */

  3. #3
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Arrays:
    Code:
    int myArray[10]; //starts an integer array with 11 elements 
    //because arrays start at 0
    myArray[3] = 10;
    //puts 10 into myArray[3] (the fourth element
    for(int i=0; i<11; i++)
        myArray[i] = i;
    //fills up my array with numbers
    for(i=0;i<11;i++)
        cout<<myArray[i]<<endl;
    //writes out all the elements of myArray
    //easier than writing
    //cout<<myArray[0];
    //cout<<myArray[1];
    //ect

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    5

    thanks

    thanks for the help on arrays anyone on strings or classes??

  5. #5
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    classes (and structs for that matter) are simply a collection of different data types. They may also include class-specific functions which are only used when handling class objects. Time for a quick example...
    Code:
    class Person
    {
    public:
       char firstName[ 30 ];
       char lastName[ 30 ]
       int age;
    };
    That is a very simple class. The bit that says public means that the data can be accessed from outside the class, eg:
    Code:
    void main( )
    {
       Person me;
       me.firstName = "bob";     //uses the . operator to access the different bits of the Person class
       me.lastName = "builder";
       me.age = 100;
    }
    Thast just the beginning really, if you want more just ask - theres loads to know about classes
    Couldn't think of anything interesting, cool or funny - sorry.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Q: Pointers to Classes '->' notation
    By Howie17 in forum C++ Programming
    Replies: 2
    Last Post: 12-12-2008, 10:09 AM
  2. two-dimensional dynamic array of pointers to classes
    By Timo002 in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 07:18 AM
  3. Pointers to Classes || pointers to structures
    By C++Child in forum C++ Programming
    Replies: 24
    Last Post: 07-30-2004, 07:14 PM
  4. Help With pointers in classes.
    By indigo0086 in forum C++ Programming
    Replies: 12
    Last Post: 10-10-2002, 03:03 PM
  5. accessing arrays with pointers
    By Nutka in forum C Programming
    Replies: 9
    Last Post: 09-30-2002, 09:19 PM

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