Friday, July 31, 2009

C++ beginners question??

Im a beginner to the new C++ code language and i was wondering what are classes and pointers and functions and what do they do. Pls give examples.


ALso what is the Win32 API and how do i use it or create it whatever.


PLS note: I am a beginner NO TEASING.

C++ beginners question??
fristly Classes :


you can create your own classes, the purpose in designing classes is, if you want to work as software designer, once you create a class any other user can use its properties easily we as designer just make things easy.





the class contains its own variables, functions, and constructor.





Secondly Pointers:


the array is a pointer, but created through c++ developers, in the array list if you have 10 cells you cant delete or remove the 7th cell but in pointer you can, and connect the 6th cell with 8th cell, and also pointers save memory.





Thirdly Functions:


rather than writing a large code in "void main" you can easily divid your code into pieces that what function does.





if you want any thing Specifically contact me.





and good luck.
Reply:check out www.functionX.com


it has great tutorials
Reply:The items you asked about are fundamental. To keep it simple I am going to avoid code and just explain the concepts. If you understand this learning how to code will be easier. Pointers are what make C++ and C such poweful languages. A pointer is just it is a place set aside in memory that points to another place in memory. What are pointers good for it may help to consider a classic example. You have a paper with the address to a house it is not the house but it points to the location. If you want something in that house the address would very usefull. In C++ and C strings are null terminated arrays. All elements in an array are place next to each other. So a pointer to a variable of type char would be the beginning of your string. To understand what else you can do with pointers it would help to understand the other two language elements you talked about. Lets start with functions. A function is a small program within a program. Functions are sets of statements organized to perform some task in a program. You can also pass information for the function to act on. This information passed to the function is called parameters. Here is how you might use it. Lets pretend you are writing a program that is going to be the next great thing in rocket science. This means you are doing alot of math with exponents. So you may want to have some part of the program there to do this. You would pass the number and the power you wanted to raise it to. You program would then multiply that number the number of time you sepcified in the power parameter and return the number back to the program. In many programming languages functions are required to return a value. In the languages that force you to return a value they provide a mechnisim to group statements that just perform some desirable task these they call subroutines. C++ makes no such distinction subroutines and functions are one and the same. The catch is that when you declare a function you must declare the type of value that the function returns. C++ provides a special type for a function that is a subroutine and returns no values the type is void. Objects are not that hard once you look around you . You see a monitor that you are looking at this content on a light on your desk perhaps a phone. That all objects are they are just a way of describing things. Objects have chacteristics like color, brandname maybe some others. Charchterisits in object lingo are properties Objects may have other objects as part of them for instance a lamp object has a switch object. Objects also can be acted upon you could for instance push the switch. These actions are called events. The event may cause somethings to happen like the bulb emit light the function that the event calls to illuminate is a method. Occasionally there are goups of objects that share charcteristics like a car and a boat they both speed up and slow down. They both turn left a turn right. Although these are the same action a car is not a boat. But wouldn't it be nice if you could describe what both things have in common in a class and have both use them. The answer is inheritance a car is not a boat but both a car and a boat are vehicles. In the vehicle class I could describe these actions have the car and boat inherit that and then go on and just describe car what is unique to car and in boat what is unique to boat. car.pressBrake Boat.dropAnchor. Often times people will have groups of classes and functions they use over and over again in different programs so they will group them together in one file they then will compile this file so that they are already machine code. These files are the infamous dll's. The Win32 API is a collection of these dll's to expose various windows services. There are some for file management some for network management, some that control hardware. You declare which dll you are going to use then call the functions that you want to use as if you wrote it in you own program. Win32 API stands for Windows 32 bit Application Interface. I know this is pretty simplified without code but if you know what it is, then understanding the code that you are reading about is easier. I hope this helps


No comments:

Post a Comment