init: ex00-02
This commit is contained in:
25
ex02/Makefile
Normal file
25
ex02/Makefile
Normal 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
BIN
ex02/bin/ref_vs_ptr
Executable file
Binary file not shown.
0
ex02/main.cpp
Normal file
0
ex02/main.cpp
Normal file
18
ex02/src/main.cpp
Normal file
18
ex02/src/main.cpp
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user