Thread: Classes

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220

    Classes

    I was reading the tutorial of classes and i didnt understood anything! help me if you could explain to me i would be very happy ty!

  2. #2
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220
    oh! and typecasting too plz thank you !

  3. #3
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    step 1, turn off the iPod.
    step 2, read the pages, don't just look at the pictures.
    step 3, don't read the next sentence until you understand the current sentence you are reading.

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Quote Originally Posted by Scarvenger
    I was reading the tutorial of classes and i didnt understood anything! help me if you could explain to me i would be very happy ty!
    Do you know what an array is? A rudimentary explanation of a class is that it's like an array except that you're not limited to storing one type of data in it. With an array, each element of the array has to be the same type. With a class, you can store different types of data in an object of the class. Here is an example:
    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    class MyClass
    {
    public:
    	string name;
    	int age;
    	double height;
    };
    
    
    
    int main()
    {
    	
    	int myArray[] = {1, 2, 3}; //create an array
    	cout<<myArray[0]<<endl;
    	cout<<myArray[2]<<endl;
    	cout<<endl;
    
    	MyClass data; //create an object of the class
    	data.name = "Sally";
    	data.age = 18;
    	data.height = 150;
    
    	cout<<data.name<<endl
    		<<data.age<<endl
    		<<data.height<<endl;
    
    
    	return 0;
    }
    The class name is the type of the variable.
    oh! and typecasting too plz thank you
    It's not important until you get into advanced C++, so don't worry about it.
    Last edited by 7stud; 10-24-2005 at 02:36 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 05:38 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM