init: ex00-02

This commit is contained in:
Camille Chauvet
2023-05-23 15:38:05 +00:00
commit f1d178366c
18 changed files with 236 additions and 0 deletions

25
ex02/Makefile Normal file
View File

@ -0,0 +1,25 @@
CXX = c++
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror -g -O0
SRCDIR = src
OBJDIR = obj
BINDIR = bin
EXECUTABLE = ref_vs_ptr
SRCS = $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
all: $(BINDIR)/$(EXECUTABLE)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
$(BINDIR)/$(EXECUTABLE): $(OBJS)
$(CXX) $(CXXFLAGS) $^ -o $@
clean:
rm -rf $(OBJDIR)/*.o
fclean: clean
rm -fr $(BINDIR)/$(EXECUTABLE)
re: fclean all

BIN
ex02/bin/ref_vs_ptr Executable file

Binary file not shown.

0
ex02/main.cpp Normal file
View File

18
ex02/src/main.cpp Normal file
View File

@ -0,0 +1,18 @@
#include <ostream>
#include <string>
#include <iostream>
int main()
{
std::string string = "HI THIS IS BRAIN";
std::string* stringPTR = &string;
std::string& stringREF = string;
std::cout << &string << std::endl;
std::cout << stringPTR << std::endl;
std::cout << &stringREF << std::endl;
std::cout << string << std::endl;
std::cout << *stringPTR << std::endl;
std::cout << stringREF << std::endl;
}