Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cs-142:cars [2014/10/23 15:13] (current)
kseppi created
Line 1: Line 1:
 +<code cpp> 
 +#include <​iostream>​ 
 +#include <​iomanip>​ 
 +#include <​math.h>​ 
 +#include <​string>​ 
 +#include <​fstream>​ 
 +#include <​sstream>​ 
 +#include <​vector>​ 
 +  
 +using namespace std; 
 +/* This is a simple example of a class that has data and functions */ 
 +class car { 
 +public: 
 + double speed; 
 + double milage; 
 + void start() { 
 + speed = 0; 
 + cout <<"​Vroom"<<​endl;​ 
 +
 + void accelerate(double how_much) { 
 + speed += how_much; 
 +
 +}; 
 +  
 +int main() 
 +
 + car my_car; 
 + my_car.start();​ 
 + my_car.accelerate(5);​ 
 + cout << my_car.speed<<​endl;​ 
 + my_car.accelerate(5);​ 
 + cout << my_car.speed<<​endl;​ 
 + system("​pause"​);​ 
 +
 +</​code>​
cs-142/cars.txt · Last modified: 2014/10/23 15:13 by kseppi
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0