hello.
im reading the tutorial's on c++ programming i just got to the one on object oriented programming and i don't get it at all
if any 1 can give me some more info on it i would relly love that
thankes for your time
hello.
im reading the tutorial's on c++ programming i just got to the one on object oriented programming and i don't get it at all
if any 1 can give me some more info on it i would relly love that
thankes for your time
SeeThis
"Service of the poor and destitutes is the service of the God"
Normative Changes to ISO/IEC 9899:1990 in Technical Corrigendum 1
Incompatibilities Between ISO C and ISO C++
A lot of times when you are first learning programming concepts, you won't understand why you would want to do whatever it is you are reading about. However, when you're first learning a new concept, just think of it as a neat trick you can perform. Don't worry about why you would ever use the concept, just learn the mechanics of how to do it. Later, when you've written enough programs and have done enough exercises you will begin to understand more and more, and then the "why's" will slowly come into focus.Originally Posted by eric123
Here is an example of object oriented programming(OOP):
Code:#include<iostream> using namespace std; class Duck { public: void quack() { cout<<"quack, quaaaaack."<<endl; } void fly() { cout<<"flap, flap, flap"<<endl; } }; int main() { Duck myDuck; myDuck.quack(); myDuck.fly(); return 0; }
Last edited by 7stud; 11-29-2005 at 06:25 AM.
Assuming this is your first programming language, this is going to be difficult because you don't know any non-OOP languages to compare it to. Like 7stud says, don't worry about it! This could be an advantage, as OOP will seem like the natural way to program. It won't be an issue 'till you have to learn a non-OOP language.
Also, most online tutorials are quite condensed so you'll need to use several online resources, and I suggest you get your hands on a book or two. A book will contain much more information and explanation than a simple online tutorial. For example Accelerated C++ by Koenig and Moo is about 350 pages. Teach Yourself C++ In 21 Days, by Jesse Liberty is over 700 pages! (These are both beginning books that essentially cover the same topics as the tutorial.)
Sticking with ducks....
In C (a non-OOP language) you can have structures like this:
DuckDaffy.color
DuckDonald.age
But, you cannot have functions "inside" the structure. If you want to change the color or age variable you'll have to write an external function or statement that reaches-in and updates the variable.
With C++ you can also have functions inside classes (and structures) like this:
DuckDaffy.IncrementAge()
DuckDonald.IncrementAge()
The ability to include functions inside classes allows you to encapsulate functionality.
With OOP, you can also use inheritance... This allows you to call function like AnimalSound() to make a duck quack or a dog bark:
DuckDaffy.AnimalSound(); // Quack
DogSpot.AnimalSound(); // Bark
Last edited by DougDbug; 11-29-2005 at 02:09 PM.
ok thanks for the help i would have started whit sometig difrent then c++ but i didn't no about any of the others whine i started i whanted to larn c++ so i wold no how to work this open source game i found=)
Open Source programs are created for people that know how to program so they can download and change as they wish, they're not really for anyone to download and try to figure out.
Think of an airplane. It's usually a good idea to learn how to fly before you go off and purchase one rather than buying it and seeing what the instruction manual tells you.
Sent from my iPadŽ
I am also new to object oriented concept (I write programs with C). This summer, i started to learn Java and see that object oriented concept can be fully understood byJava. I recommend you to get a Java tutorial and read it, not for writing the Java code, for learning the basic concepts. The class hierarchy, inheritance, function overload etc...