#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
string name;
string color;
int age;
cout << "what is your name: \n";
cin >> name;
cout << endl;
cout << "what is your favorite color: \n";
cin >> color;
cout << endl;
cout << "oh..and what is your age: \n";
cin >> age;
cout << endl;
cout << "name: " << name << endl;
cout << "color: " << color << endl;
cout << "age: " << age << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
using namespace std;
const int SECERT_NUM = 11213;
const int PAY_RATE = 18.35;
int main()
{
int one, two, SECERET_NUM;
int hours = SECERT_NUM + 3;
double first, second, three;
string paycheck;
one = 18;
two = 11;
first = 25;
three = 3;
second = first * three;
paycheck = hours * PAY_RATE;
cout << first << " " << second << SECERET_NUM << endl;
cout << "wages = " << second << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
note
above should have double for the "const"
The C programming language is generally considered a structured programming language, while C++ is object-oriented. What enhancements were made to C++ to make it object-oriented? What types of applications are better suited to structured programming? object-oriented programming?
The difference(s) is Polymorphism: Instead of writing logic as “if this do XYZ; if that do ABC” we define the shape and it draws itself
Encapsulation: it’s the ability to group/bundle data and code in one place to hide from the outside world
Inheritance: this gives you the ability to extend objects/structure that are already in place.
Say you have Cup object. In structured code, you can have it be either empty or full.
In OOD you can have it be full, empty, (replacing full with )pop, water, cool aid, anything you want.
It’s really up to the programmer what they want to do, you can do almost anything in structured that you can in OOD, but OOD makes it so much easier because of the things that were implemented(see above)
after thinking about it for a bit more, I have to agree with one of the other students, things such as payroll would be better for constructed and games would be better for OOD
reason
if you have a payroll, you have don't have any or very little objects, and because of that you dont have to add any/few functions for them to interact with other objects if there are any
in gmaes, you have so many things that need to be defined, user characters, fireballs, monsters, user to user actions. It would take you a very long time to do in constructed
No comments:
Post a Comment