Learn C++ Oop

Introduction: Learn C++ Oop

hi, in this instructable you will learn the basics of c++ oop, hopefully you enjoy!!!!!!

Step 1: Making a Class

we are going to start by creating a class and naming it Website:

class Website

{

};

Step 2: Making It Public

now we will add the key word public to the class to make the code we write in the class accesible in other scopes:

class Website

{

public:

};

Step 3: Creating Our Variables in the Class

now we will create variables in the class (these variables are the atributes of our objects):

class Website

{

public:

//don't forget: #include <string> at the top of your file

string name = "web";

int users = 0;

};

Step 4: Making an Object

now that we have our class lets make objects out of it:

int main()

{

Website instructable;

return 0;

}

Step 5: Creating Atributes for Our Object

now we will create atributes for the object using the variables we declared earlier:

int main()
{

Website instructable;

instructable.name = "instructable";

instructable.users = 10000;

return 0;

}

Step 6: You Finished!!!!

now you finished, hopefully you learned something from this tutorial, well done on completing this instructable!!!!!

Be the First to Share

    Recommendations

    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest
    • Rice & Grains Challenge

      Rice & Grains Challenge
    • Lamps Challenge

      Lamps Challenge

    Comments