Beruflich Dokumente
Kultur Dokumente
anos, parte 1
Eduardo Felipe Castegnaro
Projeto UPGRADE!
22,5
15
7,5
0
6 8 10 12 14 16 18 20
Regular Bom Melhor
7
Horas acumuladas
0
4 6 8 10 12 14 16 18 20
Idade
Chaucer (1340-1400)
#include <iostream>
uniqua:~/cpp$ ./a.out
Hello, World!
#include <iostream>
#include <iostream>
{
std::cout << "Hello, World!" << std::endl;
return 0;
}
• Dualidade proveniente do C
• Não existem strings em C
• Existe a classe de string em C++
//Declare
int square(int number);
//Define
int square(int n)
{
return n * n;
}
//Define
void print(std::string str)
{
std::cout << str << std::endl;
}
void by_copy(std::string a) {
a[0] = 'X';
}
void by_ref(std::string& a){
a[0] = 'Y';
}
namespace first {
int var = 5;
}
namespace second {
double var = 3.1416;
}
*iptr = 6;
std::cout << iptr << std::endl;
std::cout << *iptr << std::endl;
return 0;
}
i = i + 2;
std::cout << *i << std::endl;
return 0;
}
void by_pointer(int* i) {}
void by_ref(int& i) {
std::cout << i << std::endl;
}
int& get_ref() {
int i = 5;
return i;
}
struct item {
int pos;
};
class item {
int pos;
public:
int get_pos() { return pos; }
void set_pos(int p){ pos = p;}
};
class rectangle {
public:
rectangle(int w, int h) {
_w = w;
_h = h;
}
int area() { return _w * _h; }
private:
int _w, _h;
};
class rectangle {
public:
rectangle(int w, int h)
: _w(w), _h(h)
{
}
int area() { return _w * _h; }
private:
int _w, _h;
};
class Car {
public:
Car(int tp)
:type(tp) {}
int type;
};
void print_car(Car c) {
std::cout << c.type << std::endl;
}
class Car {
public:
explicit Car(int tp)
:type(tp) {}
int type;
};
void print_car(Car c) {
std::cout << c.type << std::endl;
}
class Car {
public:
Car(int tp) :type(tp) {
std::cout << "Car()" << std::endl;
}
Car(const Car& c) {
type = c.type;
std::cout << "Copy Car()" << std::endl;
}
int type;
};
class Vehicle {
public:
Vehicle(int tp)
: type(tp) {}
int type;
};
struct Vehicle {
virtual void honk(){
std::cout << "HONK" << std::endl;
}
};
void honk_it(Vehicle* v) {
v->honk();
}
struct Car {
std::string honk() { return sound; }
std::string sound;
};
struct Car {
std::string honk() { return sound; }
std::string sound;
};
struct Car {
std::string honk() { return sound; }
std::string sound;
};
struct Ninja {
std::string yell() { return level; }
std::string level;
};
struct Car {
std::string honk() { return sound; }
std::string sound;
};
void honk_car() {
Car* car = new Car();
car->sound = "HONK!";
std::cout << car->honk() << std::endl;
}
We’re hiring!
quinta-feira, 27 de maio de 2010