idk
This commit is contained in:
parent
0dc2b875d4
commit
cc53df2dab
5
Makefile
5
Makefile
@ -16,6 +16,11 @@ sheet02:
|
|||||||
chmod +x build/sheet02
|
chmod +x build/sheet02
|
||||||
build/sheet02
|
build/sheet02
|
||||||
|
|
||||||
|
sheet03:
|
||||||
|
g++ src/sheet03.cpp -o ./build/sheet03
|
||||||
|
chmod +x build/sheet03
|
||||||
|
build/sheet03
|
||||||
|
|
||||||
pizza:
|
pizza:
|
||||||
g++ src/pizza.cpp -o ./build/pizza
|
g++ src/pizza.cpp -o ./build/pizza
|
||||||
chmod +x build/pizza
|
chmod +x build/pizza
|
||||||
|
15
headers/MyType.h
Normal file
15
headers/MyType.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef MYTYPE_H
|
||||||
|
#define MYTYPE_H
|
||||||
|
#include <string>
|
||||||
|
struct MyType{
|
||||||
|
std::string name;
|
||||||
|
unsigned age;
|
||||||
|
|
||||||
|
MyType(std::string n, unsigned a);
|
||||||
|
~MyType();
|
||||||
|
MyType(const MyType &t);
|
||||||
|
MyType& operator= (const MyType &t);
|
||||||
|
MyType(MyType &&t);
|
||||||
|
MyType& operator= (MyType &&t);
|
||||||
|
};
|
||||||
|
#endif
|
11
src/MyType.cpp
Normal file
11
src/MyType.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "../headers/MyType.h"
|
||||||
|
#include <string>
|
||||||
|
std::string name;
|
||||||
|
unsigned age;
|
||||||
|
|
||||||
|
MyType(std::string n, unsigned a) : name(n), age(a) {std::cout << "ctor\n";}
|
||||||
|
~MyType() {}
|
||||||
|
MyType(const MyType &t) { std::cout << "copy ctor\n";}
|
||||||
|
MyType& operator= (const MyType &t) { std::cout << "copy ass ctor\n"; return *this;}
|
||||||
|
MyType(MyType &&t){std::cout << "move ctor\n";}
|
||||||
|
MyType& operator= (MyType &&t) { std::cout << "move ass ctor\n"; return t;}
|
16
src/sheet03.cpp
Normal file
16
src/sheet03.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include "../headers/MyType.h"
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
MyType j("jj", 69);
|
||||||
|
MyType cj(j);
|
||||||
|
MyType caj("jj",420);
|
||||||
|
caj = j;
|
||||||
|
MyType mj(std::move(j));
|
||||||
|
MyType maj("jj", 69);
|
||||||
|
maj = std::move(cj);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user